diff --git a/doc/fastly-configuration.rst b/doc/fastly-configuration.rst new file mode 100755 index 00000000..8e2336ad --- /dev/null +++ b/doc/fastly-configuration.rst @@ -0,0 +1,43 @@ +.. _fastly configuration: + +Fastly Configuration +------------------- + +Caching is enabled by default. All requests that are marked as cachable will be cached. + +Tagging +~~~~~~~ + +Fastly supports :term:`tagging` out of the box. +Requests can be tagged using a custom header named ``Surrogate-Keys``. + +Purge +~~~~~ + +Fastly supports two types of deletion of cached items using tags: + +1. Soft Purge: This is the default behavior. It will mark the cached item as stale and will serve the stale item until the TTL expires. Once the TTL expires, the stale item will be evicted from the cache and the next request will be fetched from the origin. +2. Purge: This will immediately evict the cached item from the cache and the next request will be fetched from the origin. + +There are different ways to purge the cache: +1. Using Tags +2. Using URLs + +Cache Header +~~~~~~~~~~~~ + +To specify how long items should be cached you can use the ``Surrogate-Control`` header. +Using this header enables you to use the ``Cache-Control`` header to specify the cache duration for browsers. + +Actually this package doesn't support the ``Surrogate-Control`` header. +To configure the ``Cache-Control`` you either have to set ``Surrogate-Control`` yourself or +configure the ``Cache-Control`` header in your fastly configuration. + +.. code-block:: none + + set beresp.http.Surrogate-Control = beresp.http.Cache-Control; + // Add your rules here + if (req.url ~ "\.(css|js|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|woff|woff2|svg|ico)") { + } else { + set beresp.http.Cache-Control = "no-store, max-age=0"; + }