Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics - is ga.js cached?

This is the code google recommends you use to call in the ga.js file:

(function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
          })();

as the file is inserted into the dom does this prevent the js file from being cached by the browser?

like image 937
pedro5000 Avatar asked Mar 03 '11 16:03

pedro5000


Video Answer


1 Answers

No. Caching is based on response headers for the ga.js file. It is dynamically inserted so that its loaded asynchronously, meaning the load doesn't block the browser from doing other activities (rendering, painting etc). A few browsers understand the async attribute in the script tag. Note the

ga.async = true;
like image 175
Aravindan R Avatar answered Oct 04 '22 14:10

Aravindan R