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]

1 Answer 1


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.

  • 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... Apr 27, 2012 at 0:45
  • Marking question as answered, even though it hasn't solved my particular issue... Apr 27, 2012 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, 2013 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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