docbrown/docs/backend/fastly.md
Alex 397734b29c
Generalize Fastly rake task (#7349)
* Generalize Fastly rake task

- Update Rubocop to disable DescribeClass on rake task specs

* Change default Fastly ENV vars to ""

* Move snippet name to ENV

* Update ENV to FASTLY_WHITELIST_PARAMS_SNIPPET_NAME

* Add FASTLY_WHITELIST_PARAMS_SNIPPET_NAME to the docs

* Update docs

* Quick refactor
2020-04-22 11:49:54 -04:00

2.1 KiB

title
Fastly

What is Fastly?

Fastly is a third party service we use for caching on the edge. It allows us to scale up and serve our millions of visitors quickly and efficiently.

If you want to learn more about we use Fastly, check out this talk that one of our founders, @benhalpern, gave at RailsConf 2018 talking about how we made our app so fast it went viral.

Whitelisting query string parameters

In the context of contributing, here's what you need to know about Fastly. In order for our servers to receive any sort of query string parameters in a request, they must first be whitelisted in Fastly. For example, if you're creating a new API endpoint or updating an existing one to accept new parameters, you'll need to update Fastly.

The reason we whitelist parameters in Fastly this way is so we don't have to consider junk parameters when busting the caches. Check out our CacheBuster to see examples of this.

Previously this was a manual process done by an internal team member. Now we do it programmatically using the Fastly gem as of this pr.

How it works

We created a new file, config/fastly/whitelisted_params.yml, to house all of the whitelisted params in Fastly.

If you need to update this list, simply update this file. It's as easy as that!

Fastly is not setup for development.

In production

If you have Fastly configured in Production and have a similar custom VCL script to whitelist query string params, make sure you've set the FASTLY_WHITELIST_PARAMS_SNIPPET_NAME ENV variable with the name of the VCL snippet you have configured in Fastly.

Whitelisted params on Fastly are updated automatically when a production deploy goes out unless this key is not set (i.e. you don't have a similar custom VCL setup).

We do this by executing bin/rails fastly:update_whitelisted_params in our release-tasks.sh script.