Skip to content

Instantly share code, notes, and snippets.

@sergejmueller
Last active December 14, 2021 09:50
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save sergejmueller/b83df992cce9b25442f523bb0f5123ee to your computer and use it in GitHub Desktop.
Save sergejmueller/b83df992cce9b25442f523bb0f5123ee to your computer and use it in GitHub Desktop.
Embedded Google Analytics: Fix “Leverage Browser Caching” Warning on Nginx
<html>
<!-- ... -->
<!-- Embed analytics.js as local file -->
<script src="/analytics.js"></script>
</html>
server {
### ...
location = /analytics.js {
# Proxy to google-analytics.com
proxy_pass https://www.google-analytics.com;
# Custom expires time
expires 1y;
}
### ...
}
@milllan
Copy link

milllan commented Sep 7, 2017

Doesnt work anymore ?

I get this google error page

  1. That’s an error.

The requested URL /analytics.js was not found on this server. That’s all we know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment