JavaScript expires, cannot be set to 12 months

I am trying to speed up the loading of my site. I used the tool YSlowto analyze the website and check out some of the improvements. My first step is to cache static files. So I want to set the expires headers for the javascript file, but this will not work. I have included javascript in HTML as follows:

<script type="text/javascript" src="//a.ph3nx.com/b.js"></script>

Then I modified the Apache2 httpad.conf file as follows:

ExpiresActive On
ExpiresDefault "access plus 1 minutes"
ExpiresByType text/javascript "access plus 12 months"

The problem is that the javascript file still has a validity period of 1 minute. Hope you can help me, thanks!

Decision:

ExpiresByType application/javascript "access plus 12 months"

+5
source share
1 answer

Try using this code:

  ExpiresByType text/javascript "access plus 12 month"
  ExpiresByType application/x-javascript "access plus 12 month"
  ExpiresByType application/javascript "access plus 12 month"

You can also cache your files using .htaccess:

  <FilesMatch "\.js$">
  Header set Cache-Control "max-age=172800, public, must-revalidate"
  </FilesMatch>
+3

All Articles