Configuration: Content aware key caching
Origin shield configuration
Nginx
Nginx by default generates cache keys using the the backend host name, schema
(e.g., https or http) and the full URI (including query string parameters). The
following code snippet is an example of how to configure the proxy_cache_key
directive from Nginx. In this example, we use the $host
(request HOST
Header) to generate the key and not the default proxy_host
(backend server
Host). This makes sure to preserver the same cache key regardless of different
backend servers changes.
proxy_cache_key "$scheme$host$request_uri";
Varnish Cache
Varnish Cache by default generates the cache key or also known as hash key based on the URI and the Host header of the request. In case the Host header is not provided by the client, Varnish will use the IP address of the backend server to generate the cache key.
Note
Both Nginx and Varnish Cache generate cache key based strings of the request host header and URI, therefore, altering the value or the order of the query string parameter will generate different cache key. We will discuss in more detail in Mitigate malicious requests section on how to limit the specific query parameter requests.