docbrown/docs/backend/fastly.md
Alex cc6249beff
[deploy] Update whitelisted params on Fastly on deployments (#7279)
* Add Fastly whitelisted params

* Create FastlyVCL::WhitelistedParams.update service

* Add specs

* Create rake task to call new service

* Add rake task to setup script

* Add documentatoin

* Move sort inside params_to_array method

* Rename VCL_REGEX to VCL_DELIMITER

* Add PR URL to docs

* Move snippet name to SNIPPET_NAME constant

* Refactor setting content

* Rename params_to_array to params_to_sorted_array

* Change guard and log success on update

- Return early if params are equal
- Log success message to Rails.logger on update
- Log params diff to Datadog

* Return true explicitly

* Move rake task execution from to release-tasks

* Remove unnecessary environment guard in task

* Remove duplicate code param

* Refactor string from build_content

* Remove reliance on sort

* Reorder logging to implicitly return true

* Update docs to reference release-script.sh

* Update docs

* Update whitelisted params

* Fix params_updated? bug and add more specs

* Remove duplicate param...oopsie!
2020-04-16 15:11:57 -04:00

1.8 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

Whitelisted params on Fastly are updated automatically when a production deploy goes out.

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