Skip to content

Commit c91dbdf

Browse files
authored
Merge pull request #547 from DemigodCode/2.x
Add Fastly configuration rst
2 parents 18b4f0a + cc388ec commit c91dbdf

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

doc/fastly-configuration.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. _fastly configuration:
2+
3+
Fastly Configuration
4+
-------------------
5+
6+
Caching is enabled by default. All requests that are marked as cacheable will be cached.
7+
8+
.. note::
9+
10+
Please read the `Fastly documentation <https://docs.fastly.com/>`_ carefully to set up your caching correctly.
11+
12+
Tagging
13+
~~~~~~~
14+
15+
Fastly supports :term:`tagging` out of the box.
16+
Configure the tag header to ``Surrogate-Keys``. (``fos_http_cache.tags.response_header`` if you use FOSHttpCacheBundle)
17+
18+
Purge
19+
~~~~~
20+
21+
Fastly supports two types of deletion of cached items using tags:
22+
23+
1. Soft Purge: This is the default behavior. It will mark the cached item as stale. Stale items *may* still be served (e.g. with the ``stale-while-revalidate`` or ``stale-on-error`` cache control headers). Once the TTL expires, the stale item will be evicted from the cache and the next request must be fetched from the origin.
24+
2. Purge: This will immediately evict the cached item from the cache and the next request will be fetched from the origin.
25+
26+
There are different ways to purge the cache:
27+
28+
1. Using Tags
29+
2. Using URLs
30+
31+
Cache Header
32+
~~~~~~~~~~~~
33+
34+
To specify how long items should be cached you can use the ``Surrogate-Control`` header.
35+
Using this header enables you to use the ``Cache-Control`` header to specify the cache duration for browsers.
36+
37+
Currently, FOSHttpCache does not yet support the ``Surrogate-Control`` header.
38+
To configure the ``Cache-Control`` you either have to set ``Surrogate-Control`` yourself or
39+
configure the ``Cache-Control`` header in your Fastly configuration.
40+
41+
.. code-block:: none
42+
43+
set beresp.http.Surrogate-Control = beresp.http.Cache-Control;
44+
// Add your rules here
45+
if (req.url ~ "\.(css|js|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|woff|woff2|svg|ico)") {
46+
} else {
47+
set beresp.http.Cache-Control = "no-store, max-age=0";
48+
}

doc/proxy-configuration.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Proxy Server Configuration
44
==========================
55

6-
You need to configure the proxy server of your choice (Varnish, NGINX or Symfony
6+
You need to configure the proxy server of your choice (Varnish, NGINX, Fastly or Symfony
77
HttpCache) to work with FOSHttpCache. These guides help you
88
for the configuration for the features of this library. You will still need to
99
know about the other features of the proxy server to get everything right.
@@ -12,4 +12,5 @@ know about the other features of the proxy server to get everything right.
1212

1313
varnish-configuration
1414
nginx-configuration
15+
fastly-configuration
1516
symfony-cache-configuration

0 commit comments

Comments
 (0)