Peakhour is a Content Delivery Network (CDN) that helps to speed up your website by caching and distributing your static assets among its global network. Unlike traditional CDNs that require you to upload your content to their servers and serve it from a different domain, Peakhour does this transparently, without requiring any changes to the origin website.
Peakhour CDN provides a comprehensive set of features for controlling the caching and storage of content from the origin server. These options allow you to optimise performance, reduce origin requests, and ensure that your website remains fast and responsive for your users.
CDN Settings#
- Enable CDN: This setting enables the CDN functionality on your website.
- Soft purge: This setting determines how Peakhour will handle cache purging. Enabling this feature will default purges to only purge cached content if new content is available on the origin, instead of being purged immediately and fetching regardless if it was changed.
On Request#
The On Request phase of Peakhour's CDN allows you to control how requests are processed by the CDN during the request handling phase of content delivery. This section covers the different options available to customize the behavior of the CDN.
Skip Cookie#
This option allows you to specify a series of cookies that your application may set on a client. If these cookies are set, Peakhour will serve fresh content, bypassing the cached asset and fetching it from the origin server. This is useful when serving dynamic content to logged-in users but not to anonymous users.
Query args#
The Query args option allows you to remove certain query arguments when considering cached resources. For example, you may want to strip UTM arguments, or gcid's.
CDN Query Handling#
Peakhour offers three options for handling assets that have a query string:
- Do not cache resources that have a query string. This is the default option and assumes that the asset is dynamically generated based on the parameters specified in the query string.
- Cache the asset along with its full query string. If this mode is selected, each permutation of the query string will result in a different cache entry.
- Cache the asset and ignore the query string. This option will cache the asset without the query string and serve the stored file, regardless of whether a request is made with different query strings.
Ignore Invalidate#
If an asset has been requested and cached without a query string (e.g., /styles.css) and then is requested with a query string (e.g., /styles.css?v=1.1), the default behavior is to invalidate the cache entry for /styles.css. Ticking the Ignore Invalidate box will prevent this from happening. Alternatively, you can change the query handling mode to cache with the query string.
Ignore Request Cache-Control#
The Ignore Request Cache-Control option allows you to ignore requests with cache-control headers. This will prevent clients from forcing the cache to fetch fresh content from the origin server by specifying this header. This is useful to override site crawlers and page speed testers that set this header.
On Response#
The On Response phase of Peakhour's CDN controls how the CDN processes and processes responses it sends to a client. This section covers the different options available to customize the behavior of the CDN on response.
Browser TTL#
The Browser TTL option allows you to force a specific cache policy for browser caching by setting the cache-control: max-age=XXX in responses.
On Origin Request#
The On Origin Request phase of Peakhour's CDN controls how the CDN processes requests to the origin server. Peakhour CDN provides several options to control how it communicates with the origin server, allowing you to optimise caching behaviour and minimise origin requests.
Serve Stale#
In the event that the origin server is unavailable, Peakhour CDN can continue serving stale cached resources. This ensures that your website remains available to users even if the origin server is down. The stale content will be served until the origin server becomes available again, at which point the cache will be refreshed with the latest content.
Normalise User-Agent for Vary#
Some origin servers return different content based on the user-agent, for example serving a different version of a website for desktop and mobile devices. To optimise caching behaviour, Peakhour CDN can normalise the user-agent to a device type, such as browser or mobile, to help flatten cached responses increasing the cache hit rate.
On Origin Response#
Peakhour CDN provides a range of options to control how it stores and caches responses from the origin server. These options allow you to fine-tune caching behaviour and optimise performance.
Implicit TTL#
If the origin response does not contain any cache headers, Peakhour CDN can use the implicit TTL value specified in the CDN settings to determine the cache time-to-live (TTL) for the cached object. This ensures that cache entries remain fresh and up-to-date without the need for explicit cache headers from the origin server.
Require cache-control for caching#
To ensure that only cacheable content is stored in the cache, Peakhour CDN can require the presence of the cache-control header in the origin response. This will prevent non-cacheable content from being stored in the cache, reducing the amount of cache storage required and ensuring that the cache is filled with content that can be served to users.
Strip cookies on store#
When storing a response in the cache, Peakhour CDN can strip any Set-Cookies headers sent by the origin. This helps to protect user privacy by preventing the storage of any potentially sensitive information in the cache.
Ignore Vary: User-Agent#
If the origin returns a Vary header with the value of User-Agent, Peakhour CDN can ignore this header for caching purposes. This ensures that responses are cached and served to all users regardless of their device type or user-agent.
Edge TTL#
Peakhour CDN provides the ability to force the TTL (time-to-live) of cached content, even if the origin returns a lower value. This can be useful for ensuring a minimum cache time for important assets, ensuring that your website remains fast and responsive even during periods of high traffic.
Custom cache tags#
If the origin returns a custom header, Peakhour CDN can use this header as a surrogate key in the cache. This allows you to tag cached responses with a key, making it easier to purge specific content from the cache as needed.
Tag separator#
If the origin returns multiple cache tags, Peakhour CDN supports separating the tags using a specified separator. This makes it possible to manage multiple tags for a single response, giving you fine-grained control over cache purging.