[Mongrel] expires header for .css

Scott Windsor swindsor at gmail.com
Tue May 6 17:18:23 EDT 2008

Is your webserver directly talking to users or are you using a proxy?

You can do this in mongrel, but generally you can configure your proxy to
serve these files directly.  It's much faster to serve them statically.

For nginx, you can use the following...

in your server block, add the following (it will statically serve and set
the expiration date to the maximum allowed for images, javascript and css).

location ~* \.(js|css|jpg|jpeg|gif|png)$ {
  if (-f $request_filename) {
    expires      max;

Note that you'll have to make sure that when you change
css/javascript/images to either create a new file or add query parameters to
defeat the caching (this is done for you in rails by default).
Additionally, if you're dynamically rendering CSS or JS, then this will
break as well.

Also make sure that you've configured gzip compression for text files
(css/javascript) in nginx as well.  This will also give you a big speed
improvement for most of your clients.

- scott

On Tue, May 6, 2008 at 1:55 PM, Scott Derrick <lists at ruby-forum.com> wrote:

> I'm using mongrel as my http server.
> I was using yslow to evaluate the performance of my web site and noticed
> I was downloading the .css file on every request???  I use one .css file
> for the whole site and I though I would be cached?
> Yslow indicates that there is no expires date/time set for the css file.
> How can I tell mongrel to send an expires header with my static content?
> thanks,
> Scott
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/mongrel-users/attachments/20080506/c50a453d/attachment.html>

More information about the Mongrel-users mailing list