WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: W3 Total Cache] Gzip and Expire Headers With Amazon CloudFront (24 posts)

  1. Kudama
    Member
    Posted 4 years ago #

    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:

    http://internetmarketingbyme.com/74/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.

  2. Frederick Townes
    Member
    Posted 4 years ago #

    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.

  3. Kudama
    Member
    Posted 4 years ago #

    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!

  4. Frederick Townes
    Member
    Posted 4 years ago #

    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.

  5. here
    Member
    Posted 4 years ago #

    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.

  6. Frederick Townes
    Member
    Posted 4 years ago #

    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.

  7. masterbassie
    Member
    Posted 4 years ago #

    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

  8. Frederick Townes
    Member
    Posted 4 years ago #

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

  9. masterbassie
    Member
    Posted 4 years ago #

    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.

  10. Frederick Townes
    Member
    Posted 4 years ago #

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

  11. Chukwudi Emmanuel Udegbunam
    Member
    Posted 4 years ago #

    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

  12. Chukwudi Emmanuel Udegbunam
    Member
    Posted 4 years ago #

    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 ;)

  13. Chukwudi Emmanuel Udegbunam
    Member
    Posted 4 years ago #

    I've figured out the 1 month part ;) remaining the missing cache expiration part ;(

  14. Frederick Townes
    Member
    Posted 4 years ago #

    Sorry, what exactly is your question?

  15. Chukwudi Emmanuel Udegbunam
    Member
    Posted 4 years ago #

    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

  16. Frederick Townes
    Member
    Posted 4 years ago #

    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.

  17. Chukwudi Emmanuel Udegbunam
    Member
    Posted 4 years ago #

    The resources are the theme files stored in my cdn which in my case is the sub-domain http://images.strictlyonlinebiz.com

  18. Frederick Townes
    Member
    Posted 4 years ago #

    In that case, you need to put the .htaccess file in the document root of that domain.

  19. Alex Rodriguez
    Member
    Posted 4 years ago #

    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.

    Just wanted to add my voice of support for this feature on a future release. Specifically for Amazon CloudFront. I was a big fan of RackSpace Cloud Files but they have some serious issues and thanks to this plugin I was able to move away from Cloud Files to CloudFront.

    Alex

  20. Frederick Townes
    Member
    Posted 4 years ago #

    Understood. I'm doing more work with origin push providers this release.

  21. MasterC3501
    Member
    Posted 3 years ago #

    i added the following to my htaccess

    # 1 YEAR
    <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
    Header set Cache-Control "max-age=29030400, public"
    </FilesMatch>
    
    # 1 WEEK
    <FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=604800, public"
    </FilesMatch>
    
    # 3 HOUR
    <FilesMatch "\.(txt|xml|js|css)$">
    Header set Cache-Control "max-age=10800"
    </FilesMatch>
    
    # NEVER CACHE
    <FilesMatch "\.(html|htm|php|cgi|pl)$">
    Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
    </FilesMatch>

    however it still shows all of these in the leverage browser caching

    * http://banners.copyscape.com/images/cs-wh-88x31.gif (expiration not specified)
    * http://stats.wordpress.com/e-201023.js (expiration not specified)
    * http://www.ecigsavings.com/Media/logo.png (expiration not specified)
    * http://www.ecigsavings.com/Media/smoke4.JPG (expiration not specified)
    * http://www.ecigsavings.com/wp-content/themes/suffusion/images/bg-gray-2.png (expiration not specified)
    * http://www.ecigsavings.com/wp-content/themes/suffusion/images/home-light.png (expiration not specified)
    * http://www.ecigsavings.com/wp-content/themes/suffusion/images/icons/bulletgray.png (expiration not specified)
    * http://www.ecigsavings.com/wp-content/themes/suffusion/images/search-button-gray-2.png (expiration not specified)
    * http://www.ecigsavings.com/wp-content/uploads/2010/01/girl_smoking_electronic_cigarette7-199x300.jpg (expiration not specified)
    * http://www.ecigsavings.com/wp-content/uploads/2010/02/blu-electronic-cigarette-starter-kit-150x150.j... (expiration not specified)
    * http://www.ecigsavings.com/wp-content/uploads/2010/02/blu-electronic-cigarette.jpg (expiration not specified)
    * http://www.ecigsavings.com/wp-content/uploads/2010/02/button.png (expiration not specified)
    * http://www.ecigsavings.com/wp-content/uploads/2010/02/girl_smoking_electronic_cigarette31-199x300.jp... (expiration not specified)
    * http://www.ecigsavings.com/wp-content/uploads/2010/02/green-smoke-electronic-cigarette-starterkit-15... (expiration not specified)
    * http://www.ecigsavings.com/wp-content/uploads/2010/02/greensmokeelectric.jpg (expiration not specified)
    * http://www.ecigsavings.com/wp-content/uploads/2010/03/asotv.jpg (expiration not specified)
    * http://www.ecigsavings.com/wp-content/uploads/2010/03/smoke-background.jpg (expiration not specified)
    * http://www.totallywicked-eliquid.com/images/pictures/new-partner-collateral/new-affiliate-scheme-2/a... (10 minutes)
    * http://www.google-analytics.com/ga.js (1 day)

    I have spent countless hours on this cause godaddy sucks so dang much that everything on their servers is disabled. I cannot use mod_expires but they said i can use mod_headers however the htaccess code will not work. I have WP total cache running and its not doing it for me im so frustrated :(

  22. Frederick Townes
    Member
    Posted 3 years ago #

    You cannot modify the headers for files you do not host.

  23. redkathy
    Member
    Posted 3 years ago #

    The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
    Can you tell me what to put in my .htaccess file to resolve this?
    All of the resources are located in the /wordpress/wp-content/themes/magazine-basic/images/ folder.

    Being a newbie I don't quite get HOW to accomplish setting the expiration. Not sure if I need another .htaccess for the images folder or add something to the one in my root?

    Thank you

  24. Frederick Townes
    Member
    Posted 3 years ago #

    For images etc, you can go to the browser cache settings tab and enable the options there and modify the expires value to obtain the result you want. W3TC will update your .htaccess file for you or provide the code to add in a notification.

Topic Closed

This topic has been closed to new replies.

About this Topic