0
votes

I am serving my content through Apache and Nginx in Webfaction. Webfaction only supports 'epxires_max' directive for its Nginx server for all the static content (images, css files, js, etc).

I tried Google PageSpeed Tool and it says this:

The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:

and then lists about 50 images that it considers I need to specify their expiration.

So my questions are:

(a) Serving content through (Apache and) Nginx (no expires_max directive included) and using memcached, do I also need to specify more expire information for my static content?

(b) Apart from 'expires_max' do I have other options?

2

2 Answers

3
votes

If you're using NGINX to serve all of your static content then adding this within the server block should do the trick:

location ~* \.(?:css|js|gif|jpe?g|png)$ {
    expires max;
    add_header Cache-Control public;
}
1
votes

Basically expire information is specified through the use of http headers, specifcally some combination of Expires, Cache-Control, and possibly Etag and `Last-Modified. See for instance http://www.mnot.net/cache_docs/ for some more info on how caching works and what the headers mean.

Setting up those headers is typically something you do in the webserver configuration:

  • For Apache you can either add the necessary config to your main apache config (if you have acces to that), or via .htaccess files. What directives you can add in those .htaccess files depends on how the AllowOverride directive is configured in the main config.
  • Nginx requires access to to main server config files, there not being a mechanism similar to .htaccess (see http://wiki.nginx.org/LikeApache-htaccess for why)

In other words you need to contact webfaction support (if it's not in their faq) and find out what options are open to you:

  • Can you add stuff to the main config yourself? (I gathered no from the comments on Matt's answer)
  • Are they willing to add config bits to the config of your virtual host if requested through a ticket?
  • What is Apache's AllowOverride set to? and consequently what can you set yourself? (see apache docs linked above)