• Hello there,

    Great plugin. Thanks for the work.

    I use nginx and fastcgi_cache for the wordpress websites I host. For some sites I can install W3TC, for some I cannot, so for me the best way to go in overall cache is do it on nginx side. All requests to dynamic pages are cached to tmpfs and purged when purge is needed. All good.
    I also use gzip_static to serve pre-gzipped assets like js, css… this makes it possible to use highest compression level (9) without the cpu overhead of on-the-fly compression, which I cannot afford on my servers.

    I’ll use W3TC for minify and CDN.

    CDN seems to work fine. My questions are regarding minify.

    W3TC seems to combine and minify my assets just fine, generating the correct link.

    I did some SIEGE with these parameters:

    Siege benchmark mode with 20 concurrent users for 120 seconds on Amazon Ec2. Target machine is m1.small, siege machine is cpu heavy.
    Siege hits only the root page of one blog and ALL ITS ASSETS as extracted from html. All .js, .css, .img etc. Combined or not, minified or not, depending on the scenario I am testing. This is how I test. It simulates a full user load on the starter page with empty cache.

    First scenario is nginx + fastcgi_cache + gzip_STATIC. No w3tc. No minified assets.
    I got a throughput of 20mb/s, response time of 0.01secs.
    That is fast enough. Almost the ec1 m1.small network out cap, which is 35mb/s. Everything is hitting cache or served as static and the only gzipping being done on-the-fly is on the dynamic page – all other assets are pre-gzipped.

    Second scenario is nginx + fastcgi_cache + gzip_STATIC (no point really, anyway) + W3TC with Minify on.
    Throughput was 8.49 MB/sec and response time was 0.11secs.
    All assets are minified and combined. Cache is being hit everytime. No php is being hit during the tests – that means nginx is serving the combined .js and .css static without passing through php5-fpm. All good.

    I believe the difference in results can only be because W3TC minified assets have to be gzipped on every hit and that makes a huge difference in cpu usage and in throughput.

    My question is: Is it possible to make W3tc save a .gz version of minified assets? Nginx will make sure that gets served instead of gzipped on the fly if you use gzip_static. That would save some cpu.

    Best regards.

    http://wordpress.org/plugins/w3-total-cache/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Ddutra,

    For the “Page cache method:” you should try using Disk Enhanced. Then the files are written to the cache directory in both .html and .html_gzip. The default level of compression is 9.

    First make sure that the files are being written to the /wp-content/cache/page_enhanced/your.domain.com directory. Then you need to make sure that the rewrite in nginx is written correctly so that it can find the file and serve it out using the .html_gzip file (not named .gz) and send the correct headers. If it can not find the file then it’s generated on the fly.

    If everything is set up correctly it will serve out the static .html_gzip file which is quite fast using nginx.

    Craig

    Thread Starter ddutra

    (@ddutra)

    Craig,
    Thanks.

    Just for the record, I do not use page cache in any way, nor do I plan to. I use fastcgi_cache (nginx) which I believe is faster and more reliable.

    My objective is minification only (for now) and images moved to S3 (which W3TC seems to do fine).

    Minification is not working as I wanted to. I do not see any .gzip (or .gz) file on the /cache/minify folder. It is not generating the gzip file.

    I’ll do some more testing later.

    Best regards.

    Ddutra,

    Oops, sorry I misread your post and started talking about page caching. The way the compressed css and js files are named is with .gzip.

    The settings I use are:

    General Settings Page:
    Minify mode: Auto
    Minify cache method: Disk

    Browser Cache Page: under css and js:
    Check “Enable HTTP (gzip) compression”.

    Minify Page:
    Check the “Rewrite URL structure”
    enable “JS minify settings:” and “CSS minify settings:”.

    My guess is that since your setup isn’t saving .gzip files, the “Enable HTTP (gzip) compression” isn’t checked.

    Craig

    Thread Starter ddutra

    (@ddutra)

    Craig,
    Not a problem, thanks.

    I am looking into this with not much luck. The more I try the more problems arise.
    Long minified assets urls are hitting php backend, being cached by fastcgi_cache.
    If I use smaller max lenght they work fine, served as static, but the combine is not that efective since I still end up with a bunch of requests.

    And I have browser cache completely off, thats handled by nginx itself. Maybe thats why (enable http (gzip)) I was not seeing any gzip files. Anyway no point in having .gzip if i need .gz. Also, both files (the .js and the .js.gz) have to be touched with the exactly same timestamp for gzip_static to work. I’ll have to find another way.

    Best regrds.

    Ddutra,

    I also use nginx to serve out static files and the first thing that I wanted to change was their compressed file naming, both .gzip and _gzip should really be .gz because most servers are already setup to serve out a .gz file.

    The way that w3tc does it is with rewrite. If a browser accepts gzip compression then it rewrites the file name to .gzip or _gzip if you are using page cache, then it changes the headers. It does not use gzip_static.

    From your description it seems like your nginx rewrite code has a problem because it’s not finding the static file and ends up using php to serve out the js or css files. When everything is correct it only uses /wp-content/plugins/w3-total-cache/pub/minify.php once to create the minimized regular and compressed file.

    What I do is add an extra small header in the rewrite code so that I know rewrite is working correctly, then once you know it’s correct just comment out the temporary header.

    Here is a post that shows my nginx configuration:
    http://wordpress.org/support/topic/prefer-gz-instead-of-gzip?replies=5

    Craig

    Thread Starter ddutra

    (@ddutra)

    Craig
    Thanks for your time.

    The only thing I want to use from W3TC is minify and combine js/css. Nothing else (for now).
    My nginx configuration is exactly as pointed by /install on W3TC menu.

    I’ll do some more testing and tail rewrite logs, use add_header for debugging etc. But something is weird on my setup.

    Best regards.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Minified assets and gzip’ is closed to new replies.