0

I am trying to set up caching through .htaccess rules on my VPS server. I made sure mod_expires and mime type detection was installed but when I run my site through gtmetrix it shows I do not have caching enabled. Here are my .htaccess rules:

# Expire headers
<ifModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType image/x-icon "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"
  ExpiresByType text/html "access plus 600 seconds"
  ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>

# Cache-Control Headers
<ifModule mod_headers.c>
#month
  <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </filesMatch>
#week
  <filesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=604800, public"
  </filesMatch>
#day
  <filesMatch "\.(x?html?|php)$">
    Header set Cache-Control "max-age=43200, private, must-revalidate"
  </filesMatch>
</ifModule>
# END Cache-Control Headers

# Turn ETags Off
<ifModule mod_headers.c>
  Header unset ETag
</ifModule>
FileETag None

# Remove Last-Modified Header
<ifModule mod_headers.c>
  Header unset Last-Modified
</ifModule>
4

1 に答える 1

0

FilesMatch ブロックに Last-Modifed を追加してみてください。このようなもの:

<FilesMatch "\.(jpg|jpeg|png|gif|js|css|ico)$">
  ExpiresDefault "access plus 10 years"
  Header  set Cache-Control "public"
  Header  set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
  Header  unset ETag 
  Header  append Cache-Control "max-age=604800, public"
</FilesMatch >
于 2013-01-19T21:46:06.647 に答える