• Resolved damaha

    (@damaha)


    Hi,

    I use the mod-rewrite option in WP Super Cache, it seems to work.

    As the plugin does not add expiry dates or max-age for images or css, I modified the .htaccess file in the cache folder (wp-content/cache/) manually and added max-ages for images and css. (I cannot use the expiry module with my virtual server, so I cannot add expiry dates.)

    I added the following code to the .htaccess file in the cache folder:

    # BEGIN Cache-Control Headers
    <ifmodule mod_headers.c>
      <filesmatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
            Header set Cache-Control "max-age=86400"
      </filesmatch>
      <filesmatch "\.(css|pdf)$">
            Header set Cache-Control "max-age=86400"
      </filesmatch>
      <filesmatch "\.(js)$">
            Header set Cache-Control "max-age=86400, private"
      </filesmatch>
    </ifmodule>

    The whole file now looks like this:
    http://pastebin.com/B4WGnTjM

    But when I check the browser caching of static assets, I still get the message: No max-age or expires for the images and the css file.

    Can anyone please help?
    Many thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter damaha

    (@damaha)

    You can look at my WordPress-site under http://www.trustablegold.de.

    Add that code to your main .htaccess file as images and css aren’t cached!

    Thread Starter damaha

    (@damaha)

    Great, it seems to work now.
    Thanks a lot!!

    I just want to confirm that it’s not possible to set caching time limits for CSS and JS, especially when you’re using a CDN.

    But, now that I’ve seen this, I guess we can write the rules to .htaccess.

    What is the recommended time to set CSS or JS. I see you have here 1 day or 86400 seconds. Any recommendation on how long to set it to if you’re using a CDN.

    This is resolved. I got the answer on the IRC channel from Donncha.

    Settings are what you’re comfortable with.

    We’re going with 172800 (2 days) for CSS and JS and images at 600 seconds (10 min) because we’re a news org that updates stories with images frequently.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WP Super Cache] – adding max-age for images/css’ is closed to new replies.