Google says "Leverage Caching" on these files. How?

I’ve got a Google webmaster’s report which lists several of the files used by my WordPress theme (.gifs, .pngs, .jpgs and .css) under a heading:

The following cacheable resources have a short freshness lifetime. Specify and expiration at least one week in the future…”

I knew that you could specify a cache expiration as a meta attribute of a page. How can you do it in a specific file?

Since I’m using WordPress, which has an htaccess file, I’d imagine I might be able to place a few rules in there relative to global file cache settings by file type. What are your thoughts?

Hi Scott,

Assuming you are using Apache, you need the module “mod_expires.so” loaded.

Then you can use the following in your server config file or htaccess:

<FilesMatch “\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$”>
Header set Cache-Control “max-age=1296000, public”
</FilesMatch>

The max-age value in this case is measured in seconds.
You could adjust the file type list to match your requirements.

For more advanced cache control, I’d recommend the “W3 Total Cache” plugin for Wordpress.