Hacker News new | past | comments | ask | show | jobs | submit login

The suggestion says to cache the js file for the analytics tracker, not to remove it.



Good luck setting caching headers on an external resource.


It's hosted by Google, so they control the cache time.


You actually can host the Google Analytics JS file locally, though I'm not sure it's an officially supported configuration.


Do you have any resources on doing this?


it's definitely not a supported config: https://support.google.com/analytics/answer/1032389?hl=en

But you can download it, and host it locally. Just update it periodically. As you can see from the changelog, it only changes every few months: https://developers.google.com/analytics/devguides/collection...

Google actually takes a few days to deploy updates to all of their servers. So a daily script to update it on your server would be fine.


Thanks for this.


You could probably proxy a file through your own server and add any headers you like. But in that case browser cannot use a version of a script cached at other sites.


Why do they only cache it for two hours? Do they want changes to be that quick to take?


Are you being funny? If not, how do you suggest they do that?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: