Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

If i'm running a WordPress website with the W3TC plugin installed, and have my static CSS/JS minified files hosted on Amazon's CDN, is there a way to serve them GZIP'd?

I have the basic understanding that you can't control the comrpession/header responses on files not hosted on your own server, but I'm using a CNAME and .htaccess should be ensuring the files are served compressed.

Has anyone got experience with this or know how to ensure the files are served compressed?

[Question has been asked on the WordPress support forum with the W3TC tag]

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

Yes, Amazon Cloudfront can now serve GZip'ed / HTML Compressed content to end users fairly easily. This used to be rather hard, but Amazon added this to Cloudfront around November 2010.

What you are looking for is called "custom origin". The gist of it is:

  1. You set up your own web server, and configure this server to correctly compress content for supporting clients, and correctly emit the proper HTTP cache control and compression headers. Once you're done with this, you may want to check it with the excellent RedBot inspector.

  2. You set up your Cloudfront distribution with your own server as the custom origin server.

  3. In your HTML, you change the paths for your static content to the Cloudfront hosted URLs.

  4. Cloudfront caches your content on their edge nodes. Cloudfront preserves the client HTTP headers when connecting to your origin server, and Cloudfront only serves up compressed content to other clients which present matching HTTP headers. Thus your origin server is in control of which clients receive compressed content, based on the HTTP headers.

share|improve this answer
    
Thanks for the great answer. W3TC creates a custom origin distribution when 'Origin - Pull' is selected from the CDN options. So it looks like everything was configured as you suggested. Perhaps it's not the CDN that's causing the issue but the W3TC plugin... –  Mike Hudson Apr 27 '12 at 0:45
    
Marking question as answered, even though it hasn't solved my particular issue... –  Mike Hudson Apr 27 '12 at 0:46
    
Confirmed that this works. Cloudfront is serving gzipped version of my stylesheet using origin pull from my server. I configured the CDN in WP Super Cache, much easier to use :) –  JimmyPena May 11 '13 at 11:08
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.