Expires headers and cache control

Hi All,

I’m trying to understand expires headers and cache control better, maybe
someone can help?

our configuration file has:

  location ~* \.(jpg|jpeg|gif|png|ico|css|js)$
    {
            error_page 404 = /404.php;
            expires 31d;
    }

Which I understand to mean that for these file types, the expiration
header
should be set to 31 days from today. However, when I load the site, it
looks like its being set 1 day ahead.

I’ve also seen a lot of examples which use “add_header Cache-Control
private;” but I don’t understand what this actually means?

Thanks for any input / help.

On Mon, Oct 25, 2010 at 12:38:37PM -0400, Ilan B. wrote:

Hi there,

Which I understand to mean that for these file types, the expiration header
should be set to 31 days from today.

Yes.

Strictly, it is for requests that are processed by this location
block. It’s limited to “these file types”, but it may not be all of
these file types, depending on the rest of your configuration. The debug
log should show you which one location block is used for each request.

However, when I load the site, it
looks like its being set 1 day ahead.

Look at the response headers of one request. “wget -S” or “curl -i”
can be useful for this. You’ll see the Expires and any Cache-Control
headers that are returned. No need to guess anything.

If it doesn’t show Expires: of 31 days in the future and the debug log
does show that this location block is being used, then something odd
is happening.

I’ve also seen a lot of examples which use “add_header Cache-Control
private;” but I don’t understand what this actually means?

Searching google for “expires headers and cache control”, the top link
for me right now is

Best Practices for Speeding Up Your Web Site - Yahoo Developer Network

which includes a section on “Add an Expires or a Cache-Control Header”
which gives a very coarse overview. The next two links are

HTTP/1.1: Header Field Definitions and
HTTP/1.1: Caching in HTTP

The first includes “14.9 Cache-Control”, which pretty much says how
things should be for that header, including what “private” means. The
second is titled “Caching in HTTP”, and is probably in more detail than
you want to know.

The fourth link is

Caching Tutorial for Web Authors and Webmasters

which describes the RFCs, and also mentions some of the real-world
aspects that may not match the ideal.

All the best,

f

Francis D. [email protected]