# Expires headers and cache control

**URL:** <https://www.ruby-forum.com/t/expires-headers-and-cache-control/198055>\
**Category:** NGINX\
**Created:** [October 25, 2010, 6:39pm UTC](https://www.ruby-forum.com/t/expires-headers-and-cache-control/198055 "2010-10-25T18:39:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [October 25, 2010, 6:39pm UTC](https://www.ruby-forum.com/t/expires-headers-and-cache-control/198055/1 "2010-10-25T18:39:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [October 25, 2010, 8:38pm UTC](https://www.ruby-forum.com/t/expires-headers-and-cache-control/198055/2 "2010-10-25T20:38:53Z")

</div>

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](http://developer.yahoo.com/performance/rules.html)

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://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) and  
[http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html](http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html)

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](http://www.mnot.net/cache_docs/)

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
