LEMP with WordPress and W3 Total Cache not caching static files.

March 20, 2014 2.6k views
Hello, Following the relevant tutorials on DigitalOcean I have managed to properly install a LEMP stack + WordPress (/usr/share/nginx/html). I've updated to PHP 5.5.9 and nginx to 1.4.6. My WordPress website is running fine. I use W3 Total Cache for the page caching, minifying (with APCu) and browser cache. However, when I'm running google pagespeed or "curl -I" command on a static resource it all says it isn't cached. Browser caching for HTML seems to be working ("curl -I http://ukuscales.com/"): HTTP/1.1 200 OK Server: nginx/1.4.6 Date: Thu, 20 Mar 2014 17:19:43 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Last-Modified: Thu, 20 Mar 2014 17:18:12 GMT Expires: Fri, 21 Mar 2014 17:18:12 GMT Pragma: public Cache-Control: max-age=86309, public, must-revalidate, proxy-revalidate Etag: 3e5fe98d138e488a20e4d8bed073aa72 X-Powered-By: W3 Total Cache/0.9.3 Vary: X-Pingback: http://ukuscales.com/xmlrpc.php But not for a static resources ("curl -I http://ukuscales.com/wp-content/themes/ut/images/vivalaukuleledrawn.gif"): HTTP/1.1 200 OK Server: nginx/1.4.6 Date: Thu, 20 Mar 2014 17:22:56 GMT Content-Type: image/gif Content-Length: 14692 Last-Modified: Thu, 20 Mar 2014 16:18:44 GMT Connection: keep-alive ETag: "532b14e4-3964" Accept-Ranges: bytes I created a nginx.conf file (in the root directory where WordPress is installed) where I have manually added the lines from the "install" tab in W3 Total Cache. My apologies if this is a stupid question, I am new to this. Any help is greatly appreciated.
4 Answers
How about adding this... ?

# Cache Static Files For As Long As Possible
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires max;
minifying (with APCu) never do this !
@wzy: Thank you, that actually fixed it!

@daniellekwint: I immediately turned it of and. Do you mean never use minify or never use minify with APCu? I would like what is the reason for this is?

Thank you!
if your WP version is 3.8.1, then W3 Total Cache doesn't work with it.

I tried that 2 weeks ago and had the same issue. if you use WP v.3.8, however, it will function without any issue.

Have another answer? Share your knowledge.