Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Is YSlow giving you an F for the /wp-content directory or for the whole site? –  Ladadadada Jan 18 '13 at 7:31
    
@Ladadadada: Appears for only select, static assets which reside in /wp-content. I posted an update. –  Mike Purcell Jan 19 '13 at 0:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.