Htaccess caching specific files

Ok, I checked a lot of websites on how to manage browser cache using the htaccess file, but it’s still not clear to me.

I want to cache certain files for one month. Otherwise, I want it to be updated every time. So I tried:

<IfModule mod_headers.c> 
    Header unset Cookie
    Header unset Set-Cookie

    #Header set Cache-Control "max-age=31536000"
    Header unset Cache-Control
    Header unset ETag
    FileETag none 
</IfModule>

<IfModule mod_expires.c>  
    ExpiresActive On
    ExpiresDefault "now"
    <Files "/css/jquery-ui.css">
      ExpiresDefault "access plus 1 month"
    </Files>
    <Files "/js/jquery-1.10.2.min.js">
      ExpiresDefault "access plus 1 month"
    </Files>
    <Files "/js/jquery-ui.js">
      ExpiresDefault "access plus 1 month"
    </Files>
    <Files "/js/analytics.js">
      ExpiresDefault "access plus 1 month"
    </Files>
    <Files "/matheos/img/*">
      ExpiresDefault "access plus 1 month"
    </Files>
    <Files "/img/*">
      ExpiresDefault "access plus 1 month"
    </Files>
</IfModule>

But it doesn’t work exactly as expected, apparently ... HTML code is not cached correctly, but for other files this does not look right. Files that I did not want to cache seem to be cached for 15 minutes (well, I can survive, but why ? ...), and for others, I can’t be sure. I think they can be cached correctly, but how can I find out ?

Anyway, does this htaccess seem right for you?

. ;)

+4
1

, ! , :

#to not cache css except jquery-ui.css
ExpiresByType text/css "now"
<FilesMatch "jquery-ui\\.css$">
    ExpiresByType text/css "access plus 1 month"
</FilesMatch>

, , , ovh. ExpiresDefault, ...

+6

All Articles