A cache key is a unique identifier for each object stored in the cache. It's generated based on specific request attributes like URL, query parameters, headers, or cookies.
Web servers and proxies like Nginx combine these attributes in cache keys to ensure that the correct version of the content is served to users. Properly configured cache keys also improve your website's performance as they prevent unnecessary server load and speed up content delivery.
If you want to modify your cache key via API, refer to our API documentation.
You can modify the structure of your cache key by adjusting variables that capture essential request information, such as URI or the value of the Host header.
Consider that enabling and updating the Cache key modification feature can invalidate your current cache and affect the cache hit ratio. Furthermore, the Purge by pattern functionality won’t work.
To modify the cache key:
1. In the Gcore Customer Portal, navigate to CDN. You’ll be directed to the CDN resources page.
2. Find the resource where you want to modify the cache key and click the CNAME to open its settings.
3. In the Cache section, click Cache key modification.
4. Turn on the Enable cache key modification toggle and add the relevant supported variables, which are listed in the following section.
5. Click Save changes to apply the updates.
You’ve successfully modified the cache key for your resource.
You can use the following variable to modify your resource’s cache key:
$request_uri
: The full original request URI. If used with the rewrite feature in conjunction with this option, this variable retains the value of the original URI, not the rewritten one. $scheme
: The protocol used in the request. $uri
: The current normalized URI in the request. The value of this variable may change during request processing. For example, it’ll change during internal redirects or when using index files.Was this article helpful?
Learn more about our next-gen CDN