Ruby Forum Ruby on Rails > Cache Control Headers

Posted by TomRossi7 (Guest)
on 23.01.2008 22:29
(Received via mailing list)
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
Posted by Keynan Pratt (keynan)
on 24.01.2008 09:13
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
Posted by TomRossi7 (Guest)
on 24.01.2008 15:26
(Received via mailing list)
Thanks so much for looking into this with me!  I'm getting desperate.

On Jan 24, 3:13 am, Keynan Pratt <rails-mailing-l...@andreas-s.net>
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.

> 2) 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:
  <link href="/css/colorpicker.css" media="screen" rel="stylesheet"
type="text/css" />

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
Posted by David Currin (dbcurrin)
on 25.02.2008 00:52
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.