Serve gzip files via Heroku Fastly plugin

When we create our javascript bundles we create a gzipped copy but I can’t figure out how to configure Fastly to serve those gzipped js files. I found some help but that seems to be via the Fastly config. The config via Heroku is a much smaller subset of config options. Is it possible to set this up for our Fastly Heroku plugin?

Thanks,
Tom

0

Comments

I'm not that familiar with the Fastly setup and api. Can you provide some extra description about what each step does. I'm guessing some of the settings are for fetching from the source and some are for the incoming request by the end-user but would be great to have that confirmed. And is gzipping on the fly or fetching pre-gzipped files from the source?

If you're unsure of your API key or service ID, use the <code>heroku config</code> command, which will give you both of these values.

If you are gzipping on your origin, then we will serve the compressed content. However, if you would like us to compress the content, you'll want to use the above Headers and Conditions to manually set up dynamic gzipping.

In Step 1, you create two conditions. The first one checks for content that can be gzipped based on the content type. In this example, it matching for the following:
text/html|application/x-javascript|text/css|application/javascript|text/javascript
Feel free to adjust this as needed for your service.

The second condition makes sure that you're Varying on the gzippable content. Again, feel free to adjust the content type as needed.

After you've created the two conditions, you set up the two headers that will use the conditions you just created.

The first header, Force GZIP, forces the content that is matched by the condition "Gzippable" to be gzipped.

The second header, Vary Encoding, caches a different version for each of the content types set by the condition "Vary on gzip". This forces the cache to respect different encodings so things don't get confused.