1

Before implementing Google Analytics on my site with the latest javaScript code directly after the body tag, I had and still have this code in my .htaccess:

ExpiresByType text/x-javascript "access plus 1 month"

Does this mean that every user that had visited the site before I implemented the analytics code will skip it due to javascript being cached?

Robin Cox
  • 1,470
  • 2
  • 16
  • 31
  • Bit of an aside, but... are you really serving your JavaScript files with a `text/x-javascript` content type? – MrWhite Sep 15 '15 at 12:31

1 Answers1

1

Short answer

As long as you serve it in the header or in a new external .js file, they won't skip it.

Long answer

Patrick Sexton from feedthebot.com explains it perfectly here:

Common caching issue

If you list your html and images to be cached for one year or some other long time period, remember that this can mean if you make a change to your pages they may not be seen by all users. This is because the users will look to cached files rather than the live ones. If you have file that you tweak occasionally (example - a CSS file) you can overcome the cache issue by using URL fingerprinting.

URL fingerprinting

Getting a fresh (not cached) file resource is possible by having a unique name. An example would be if our css file was named "main.css" we could name it "main_1.css" instead. The next time we change it we can call it "main_2.css". This is useful for files that change occasionally.

Community
  • 1
  • 1
MartinJH
  • 2,590
  • 5
  • 36
  • 49
  • 1
    Your "Short answer" answers the OP's question. However, whilst the "Long answer" goes into more detail about _caching_, it does not explain it any better - with respect to the OP's specific question. – MrWhite Sep 15 '15 at 12:30