In search of that YSlow A rating

Everyone but Justin can ignore this post, it’s just so I remember it next time.

To gzip css in apache add:

AddOutputFilterByType DEFLATE text/css

to a vhost or conf file.

To add Etags in Apache for static media make an .htaccess file in the directory holding the media and put:

FileETag MTime Size

in it.

To do the same in nginx you can do:

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

If it’s a Django site don’t forget those all important middleware classes:

'django.middleware.cache.CacheMiddleware',
'django.middleware.gzip.GZipMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
'django.contrib.csrf.middleware.CsrfMiddleware',

You still won’t get an A rating, but you might get a B and that’s close enough according to Justin who is my benchmark.

Comments 2

  1. Kristine wrote:

    I give you a B-

    Posted 24 Apr 2008 at 4:38 pm
  2. justin wrote:

    oh snap!

    Posted 24 Apr 2008 at 5:15 pm

Post a Comment

Your email is never published nor shared. Required fields are marked *