Support » Plugins » [Plugin: W3 Total Cache] Gzip and Expire Headers With Amazon CloudFront

  • First of all: I’m really blown away by this plugin. It’s like having several great plugins all in one. And so far it works great on multiple sites.

    My only problem — and it’s not so much a problem as a last detail to be refined — is that after installing and configuring W3 Total Cache I *almost* receive straight As from YSlow.. except for an E in “compress components for gzip” and and F for “Add Expires headers.”

    After a little research, it appears that this has something to do with using Amazon CloudFront for my CDN. I don’t know how to address the “Add Expires headers” bit, but I found this guide for enabling gzip for Amazon Content:

    GZIP Compression Using Amazon S3 Cloudfront CDN

    But I’d rather have this all managed by W3 Total Cache.

    So my question is: Are you planning on addressing the issues of gzip and entity tags with Amazon CloudFront anytime soon? I would assume it’s already in your road map, I’m just wondering if I should attempt the above linked process for enabling gzip on my sites or wait for an upcoming update of W3 Total Cache.

    Also, please correct me if I’ve misunderstood anything here (which is quite possible).

    Thank you again for this awesome plugin.

Viewing 15 replies - 1 through 15 (of 23 total)
  • This is a known issue and is scheduled to be added to the next release. RackSpace Cloud Files has the same issue and I’m addressing them at once. I can’t specify a timeline right now, but the implementation for compression and headers is a bit more involved than you may think.

    Understood — great! I appreciate that it won’t be done overnight or even within several weeks. I was just wondering if you were working on it. Thanks!

    In the mean time, I have a couple related questions. So I disabled CDN temporarily for one site just to do a speed comparison of it gzipped vs on the CDN.

    Now in YSlow I still get the following problems:

    CDN: F (expected here, of course)
    Add Expires Header: F
    Compress Components with gzip: B
    Configure Entity Tags: D

    So I checked another couple of sites where I hadn’t setup a CDN yet, and it got the same scores.

    I then checked with Google Page Speed and received a warning to “Leverage Browser Caching.” Upon looking at the details, this warning seems to be invoked by the same problems causing the Expires Headers and Entity tags scores in YSlow.

    Because YSlow indicated that the root domain wasn’t gzipped, I double-checked it at http://www.gidnetwork.com/tools/gzip-test.php, and sure enough, that tool indicates it isn’t gzipped either.

    So two questions:

    1. What can I do about the Expires Header and the Entity Tags. From the documentation I thought W3 Total Cache took care of these. Is there a setting I should adjust beyond the defaults?

    2. Why does both YSlow and http://www.gidnetwork.com/tools/gzip-test.php see my sites as not gzipped when I’ve double-checked that ‘gzip and deflate’ is set on each of my sites? Is this problem with the way those sites check for gzipping or is there something I could be doing wrong?

    The only settings I changed from defaults were HTTP Compression -> ‘gzip and deflate’ and Page Caching Method -> ‘disk (enhanced).’

    I hope I don’t sound ungrateful with my inquiries. I think your work is awesome and I’m super appreciative. I’m just trying to determine how to correct these minor imperfections with my YSlow and Page Speed scores (and I want to make sure my sites really are being gzipped) and I realize I’m probably just doing something wrong or misunderstanding some detail.

    Thanks!

    What can I do about the Expires Header and the Entity Tags. From the documentation I thought W3 Total Cache took care of these. Is there a setting I should adjust beyond the defaults?

    W3TC handles headers for pages. As for the other objects on your domain/subdomain you can use an included file in wp-content/plugins/w3-total-cache/ini/_htaccess to take care of other objects on your site. Later this may be directly integrated as a core feature once other higher priority features are done. Instructions are in the file.

    Why does both YSlow and http://www.gidnetwork.com/tools/gzip-test.php see my sites as not gzipped when I’ve double-checked that ‘gzip and deflate’ is set on each of my sites? Is this problem with the way those sites check for gzipping or is there something I could be doing wrong?

    That should not be the case, unless you’ve disabled compression on the page cache settings tab. Using only gzip is recommended for now as WordPress handles deflate unreliably.

    Also keep in mind that YSlow and similar tools are not perfect and do not detect all CDNs or give perfect responses for all cases, nor realize which things in a given site are beyond your control (like ads). And for example, even Google Analytic’s script is not gzip compressed. So it takes a bit of professional understanding sometimes to know where the performance wins are and what issues are of consequence.

    I was also confused about this and missed that images were not included in the advertised: “Browser caching of CSS, JavaScript and HTML using future expire headers and entity tags (ETag)”

    Is there a reference to this anywhere other than the changelog for 0.8.5? This must be a common question, and could maybe be included in the faq/elsewhere.

    0.8.5
    * Improved optional .htaccess directives (located in /ini/_htaccess)

    Gracias.

    Is there a reference to this anywhere other than the changelog for 0.8.5?

    No, the file has been there since the earliest releases.

    This must be a common question, and could maybe be included in the faq/elsewhere.

    To-date, this is the second time it’s been asked for. Since most users do not know how to work with this file it makes little sense to give them direction on it, instead it will be implemented later. For now it’s a significant performance win that pages themselves actually have headers coupled with the fact that professional CDN providers can set headers for you as well. So it’s not an oversight, it’s an conscientious decision based on priorities.

    i’m also having trouble getting gzip to work. I changed http compression to gzip only however using http://www.gidnetwork.com/tools/gzip-test.php still returns No for compression.

    I believe i have zlib enabled – not sure if this conflicts

    Can you confirm you have zlib compression enabled in your php.ini or not?

    in my php.ini zlib.compression is not On.

    the places where zlib shows up in phpinfo() is under Configure Command, Registered PHP Streams, Registered Stream Filters, and under cURL (ZLib Version 1.2.3).
    However there is no section for zlib specifically.

    Ok, well I need you to submit a bug submission via the support tab of the plugin to be able to support this.

    I made the mistake of adding most of the things in /ini/_htaccess to my .htaccess file and 404 errors started after much trial and error, it’s now working.

    To activate Expires Header and the Entity Tags add the following code ONLY to your .htaccess file

    # BEGIN Define Mime Types (in case /etc/mime.types is poorly configured or incorrect)
    <IfModule mod_mime.c>
    AddType application/x-javascript		.js
    AddType application/x-shockwave-flash	.swf
    AddType image/bmp						.bmp
    AddType image/gif						.gif
    AddType image/jpeg						.jpeg
    AddType image/jpg						.jpg
    AddType image/png						.png
    AddType image/svg+xml					.svg
    AddType image/tif						.tif
    AddType image/tiff						.tiff
    AddType image/x-icon					.ico
    AddType text/css						.css
    AddType text/htm						.htm
    AddType text/html						.html
    AddType text/plain						.txt
    AddType text/xml						.xml
    AddType text/xsd						.xsd
    AddType text/xsl						.xsl
    </IfModule>
    # END Define Mime Types
    
    # BEGIN Headers: Ensure browser caching of objects for 3 days
    # Set Expires header
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType application/x-javascript		A259200
    ExpiresByType application/x-shockwave-flash	A259200
    ExpiresByType application/wlwmanifest+xml	A259200
    ExpiresByType image/bmp						A259200
    ExpiresByType image/gif						A259200
    ExpiresByType image/jpeg					A259200
    ExpiresByType image/jpg						A259200
    ExpiresByType image/png						A259200
    ExpiresByType image/svg+xml					A259200
    ExpiresByType image/tif						A259200
    ExpiresByType image/tiff					A259200
    ExpiresByType image/x-icon					A259200
    ExpiresByType text/css						A259200
    ExpiresByType text/htm						A259200
    ExpiresByType text/html						A259200
    ExpiresByType text/plain					A259200
    ExpiresByType text/xml						A259200
    ExpiresByType text/xsd						A259200
    ExpiresByType text/xsl						A259200
    </IfModule>
    
    <FilesMatch "\.(bmp|css|ico|html?|js|tiff?|gif|jpe?g|png|svgz?|swf|txt|xsd|xsl|xml)$">
    <IfModule mod_headers.c>
    # Set Pragma header
    Header set Pragma "public"
    # Set Cache-Control header
    Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    </IfModule>
    
    # Set Entity Tag header
    FileETag MTime Size
    </FilesMatch>
    # END Headers: Ensure client-side caching of objects

    Take care guys

    I just tested my blog and I’m still getting the message The following resources are missing a cache expiration. Resources that do not specify an expiration may not be cached by browsers. Specify an expiration at least one month in the future for resources that should be cached, and an expiration in the past for resources that should not be cached:

    How do I fix this and how do I extend the code above to 1 month duration?

    Thanks in advance 😉

    I’ve figured out the 1 month part 😉 remaining the missing cache expiration part ;(

    Sorry, what exactly is your question?

    Sorry my question was despite adding the code above, when I test my blog with YSlow and PageSpeed I still get the message The following resources are missing a cache expiration

    Why is this?

    Two: I hope the code above is in order?

    Thanks

    Yes, that is ok. I cannot answer without knowing what resources it’s referring to. If they’re hosted with a 3rd party you will obviously not be able to optimize them.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘[Plugin: W3 Total Cache] Gzip and Expire Headers With Amazon CloudFront’ is closed to new replies.