rtheunissen
rtheunissen

Reputation: 7435

Why is the browser not caching my static content?

I've been trying to get this to work for hours now. The browser is downloading the file every time even though the Expires header is set to a week from now. Also tried on Firefox, same result. How can I specify that this resource is still valid and there's no need to download it every time?

Here is the Chrome network log

enter image description here

Here is the Chrome headers for the javascript file.

enter image description here

Here is my .htaccess code. I have confirmed that mod_expire is enabled.

ExpiresActive On

<FilesMatch "\.(css|js|gif|png|jpg|jpeg)$">
  ExpiresDefault "access plus 1 week"
  Header append Cache-Control "public"
</FilesMatch>

Upvotes: 2

Views: 1062

Answers (1)

vsingh
vsingh

Reputation: 6759

Change httpd.conf

<IfModule mod_expires.c>
          <FilesMatch "\.(jpe?g|png|gif|js|css)$">
                      ExpiresActive On
                      ExpiresDefault "access plus 1 year"
          </FilesMatch>
</IfModule>

Set cache to 2 years

Header set Cache-Control "max-age=63072000, public"

Upvotes: 1

Related Questions