I am currently in the process of running some optimizations for WordPress site we are soon deploying. We are using w3 Total Cache for optimizations on the site. I have recently signed up for CloudFront for a CDN and I feel this has definitely helped but we are losing gzip compression for css/js files using this.
I wanted to see if anyone had any opinions on a good way to handle this. Currently I am hosting all js/css from the webserver and it seems to give better performance (using PageSpeed Insights add on for Google Chrome)
This is more of a best practice question to help me get some insight on this scenario.
Anyone have any recommendations?
Thank you in advance.
You can pre-gzip the JavaScript and CSS files, upload them to S3 with an
application/x-gzip
HTTP header, then have CloudFront serve them out.If you automate the process as part of your build/deployment workflow, it’s pretty easy to maintain.
After spending some time testing I have found the best way for our workflow is to have the css / js assets gzip on the server rather than serving from cloudfront.
It just seems way faster to serve the gzipped files on the server side than to serve non-gzipped files from cloudfront.
I feel the suggestion that @Ryan Parman makes perfect sense if we were not editing the css/js very often. I suppose there are some ways to create a script to sync the css/js after editing but for the current project what I have suggested above works like a charm and is fast!