Skip to content

Commit

Permalink
Add Fastly configuration rst
Browse files Browse the repository at this point in the history
  • Loading branch information
DemigodCode committed Oct 16, 2023
1 parent 4f54d89 commit e9f3b59
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions doc/fastly-configuration.rst
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit e9f3b59

Please sign in to comment.