Current time: 12-13-2017, 11:25 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cache static content = F
05-20-2012, 04:38 AM
Post: #1
Cache static content = F
Greetings everyone,

I am hoping to get some clarification on how to resolve failing at "Leverage browser caching of static assets."

I am an Apache setup with my hosting company. I tried so many different setups in my htaccess file which I received from discussions here and elsewhere however I just cannot get my images to show it's caching.

Some of the things I tried are (caching for 2 days)...
---------------
<filesMatch "\.(png|jpg|ico|gif|jpeg)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</filesMatch>
--------------------------------------
<FilesMatch "\.(png|jpg|ico|gif|jpeg)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
Header unset Pragma
Header unset Last-Modified
Header unset ETag
FileETag None
</FilesMatch>
---------------------------------------------
ExpiresActive On
ExpiresDefault A0
<filesMatch "\.(png|jpg|ico|gif|jpeg)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</filesMatch>
-------------------------------------------

I just don't know what I am doing wrong or missing. I would GREATLY appreciate any assistance or feedback.

Thanks!
Find all posts by this user
Quote this message in a reply
05-21-2012, 11:21 PM
Post: #2
RE: Cache static content = F
Since you seem to have mod_expires, try:

Code:
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/gif A31536000
    ExpiresByType image/jpg A31536000
    ExpiresByType image/jpeg A31536000
    ExpiresByType image/png A31536000
    ExpiresByType image/bmp A31536000
    ExpiresByType text/css A31536000
    ExpiresByType text/javascript A31536000
    ExpiresByType application/javascript A31536000
    ExpiresByType application/x-javascript A31536000
</IfModule>

I noticed you were putting a must-revalidate in the headers. WebPagetest doesn't actually check for that yet but that effectively defeats browser caching since the browser is forced to do an if-modified-since check.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-22-2012, 08:03 AM (This post was last modified: 05-22-2012 08:06 AM by Arris.)
Post: #3
RE: Cache static content = F
You are awesome! That worked.

Since I am still making changes to some of the images I didn't want to set the Cache-Control age too far until I am finished editing some of the images. I used A604800 instead of A31536000 so it will only cache for 7 days for now.

I went from Cache static content = F to Cache static content = B.

I believe I would get an A if I set out the cache age longer as you mentioned.

Thanks again!
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)