1

I just moved a moderately busy wordpress site from shared hosting to a VPS server with 512MB ram and attempting to performance tune before I break down and buy another VPS to lighten the load. As such I am scouring the net for performance tips for nginx and came across 'gzip' and 'expires max'. From some examples I have seen, and tinkering, I made the following changes and they appear to be working correctly, but YSlow states differently.

# Entry in nginx vhost.conf
location /wp-content {
    alias /home/src/web/app/melikedev/current/code/web/wp-content/;
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public";
}

And tests from another server via curl:

mpurcell@service1 ~ $ -> curl -I -H "Accept-Encoding: gzip, deflate" -L http://melikedev.com/wp-content/plugins/sociable/css/sociable.css?ver=3.4.2
HTTP/1.1 200 OK
Server: nginx/1.0.15
Date: Fri, 18 Jan 2013 04:58:34 GMT
Content-Type: text/css
Last-Modified: Sat, 29 Dec 2012 08:50:41 GMT
Connection: keep-alive
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Pragma: public
Cache-Control: public
Content-Encoding: gzip

According to the response headers, the expires header is present, and content was zipped, but YSlow still gave an F for both. Did I miss something? Or is YSlow wrong?

-- Update --

Yslow is reporting (no expires) for 28 static components, some of which are google ad sense assets to which I have no control, but for the ones I do control, I would expect them to work per the directive in vhost.conf file. I listed one of the components Yslow is still complaining about, along with the response headers.

There are 28 static components without a far-future expiration date.

    (no expires) http://melikedev.com/wp-content/plugins/sociable/js/sociable.js?ver=3.4.2

    ....

Response headers:

mpurcell@service1 ~ $ -> curl -I -H "Accept-Encoding: gzip, deflate" http://melikedev.com/wp-content/plugins/sociable/js/sociable.js?ver=3.4.2
HTTP/1.1 200 OK
Server: nginx/1.0.15
Date: Sat, 19 Jan 2013 00:28:24 GMT
Content-Type: application/x-javascript; charset=utf-8
Last-Modified: Sat, 29 Dec 2012 08:50:42 GMT
Connection: keep-alive
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Pragma: public
Cache-Control: public
Content-Encoding: gzip

Funny thing is, the response headers to the CSS file I posted the first time are not showing up in the Yslow report, maybe Yslow doesn't like versioning js files?

Mike Purcell
  • 1,688
  • 7
  • 30
  • 53

0 Answers0