# Cache Control Headers

**URL:** <https://www.ruby-forum.com/t/cache-control-headers/126980>\
**Category:** Rails\
**Created:** [January 23, 2008, 10:29pm UTC](https://www.ruby-forum.com/t/cache-control-headers/126980 "2008-01-23T22:29:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 23, 2008, 10:29pm UTC](https://www.ruby-forum.com/t/cache-control-headers/126980/1 "2008-01-23T22:29:54Z")

</div>

I am using a controller to serve up CSS. I am having a problem with  
browsers not caching the CSS and think it is related to the Cache-  
Control header. I tried the following, but the browsers still will  
not cache:

headers[‘Cache-Control’] = ‘public’

Any ideas?

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 24, 2008, 9:13am UTC](https://www.ruby-forum.com/t/cache-control-headers/126980/2 "2008-01-24T09:13:18Z")

</div>

2 questions:

1. do you have caching disabled (sorry but tech support always has to  
know if the computers plugged in).
2. If in firefox you go to Tools/page\_info what are the values of:

-Cache Source  
-Expires  
-Meta

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 24, 2008, 3:26pm UTC](https://www.ruby-forum.com/t/cache-control-headers/126980/3 "2008-01-24T15:26:11Z")

</div>

Thanks so much for looking into this with me! I’m getting desperate.

On Jan 24, 3:13 am, Keynan P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 2 questions:
> 
> 1. do you have caching disabled (sorry but tech support always has to  
> know if the computers plugged in).

Yes, and have a used all browsers with the same the results.

> 1. If in firefox you go to Tools/page\_info what are the values of:

All of the results are taken from looking at the information on the  
css being linked on the page using the following link:

The following results are using the Rails default headers:  
Cache Source: Disk cache  
Expires: Not specified  
Meta: [nothing]

Also, the response headers (according to the web developer plugin):  
Date: Thu, 24 Jan 2008 14:00:47 GMT  
Status: 304 Not Modified  
X-Runtime: 0.08278  
Etag: “aeafc040943fac69eb986a0f90e79063”  
Cache-Control: private, max-age=0, must-revalidate  
Server: Mongrel 1.0.1  
Content-Type: text/css; charset=utf-8  
Content-Length: 2452  
200 OK

The following results are after I have switched the headers[‘Cache-  
Control’] to ‘public’:  
Cache Source: Disk cache  
Expires: Not specified  
Meta: [nothing]

Also, the response headers (according to the web developer plugin):  
Date: Thu, 24 Jan 2008 13:52:40 GMT  
Status: 304 Not Modified  
X-Runtime: 0.08174  
Etag: “aeafc040943fac69eb986a0f90e79063”  
Cache-Control: public  
Server: Mongrel 1.0.1  
Content-Type: text/css; charset=utf-8  
Content-Length: 2452  
200 OK

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 25, 2008, 12:52am UTC](https://www.ruby-forum.com/t/cache-control-headers/126980/4 "2008-02-25T00:52:04Z")

</div>

I’m having the same problem. I’m working on an app and deploying to a  
development server and I noticed recently that css background images are  
being reloaded on every page request. At first I thought it was my  
browser but then I checked the headers and I find that they’re not  
allowing caching:

Server: nginx/0.5.26  
Date: Sun, 24 Feb 2008 23:44:48 GMT  
Content-Type: text/html; charset=utf-8  
Status: 304 Not Modified  
X-Runtime: 0.01267  
Etag: “fd433ad7994a671e38210f06ac18cfbf”  
Cache-Control: private, max-age=0, must-revalidate  
Content-Encoding: gzip

200 OK

I’m not sure whether to change the Rails config or the Ngninx server  
config? Which would be correct? I’m not sure where this header is being  
set so I don’t know where to tackle the problem.
