WP Super Cache
[resolved] - adding max-age for images/css (6 posts)

  1. damaha
    Posted 5 years ago #


    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 "\.(css|pdf)$">
            Header set Cache-Control "max-age=86400"
      <filesmatch "\.(js)$">
            Header set Cache-Control "max-age=86400, private"

    The whole file now looks like this:

    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.

  2. damaha
    Posted 5 years ago #

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

  3. Donncha O Caoimh
    Plugin Author

    Posted 5 years ago #

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

  4. damaha
    Posted 5 years ago #

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

  5. tonyzeoli
    Posted 5 years ago #

    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.

  6. tonyzeoli
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Super Cache
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic