Embedded Google Analytics: Fix “Leverage Browser Caching” Warning on Nginx
server {
### ...
location = /analytics.js {
# Proxy to google-analytics.com
proxy_pass https://www.google-analytics.com;
# Custom expires time
expires 1y;
}
### ...
}
<html>
<!-- ... -->
<!-- Embed analytics.js as local file -->
<script src="/analytics.js"></script>
</html>