To offer optimal cache hit rates, Pagely's default cache configuration will ignore certain query strings, while considering others. This ensures that client-side variables, such as UTM variables, are cached as if they were never there.
Since variables that are processed on the client-side will render the same server-side content regardless of what their values are, ignoring them significantly improves performance.
On the flip side, if you're processing these UTM variables server-side (this is generally viewed as a bad idea and should be avoided), ignoring them could cause unintended consequences on your site.
In this article, we'll show you how to manage the caching behavior for various query strings.
How Cache Keys Work
Before we continue, it may be helpful to gain a better understanding of how cache keys work.
When a page is requested, the URL and other header information is processed by the gateway. From that information, what's known as a cache key is created. This is a way for subsequent requests can be identified and either serve a cached version of the page or build the page again.
For example, let's say a user visits https://example.com?myvariable=this
. A cache key is generated for that URL and subsequent requests for that same URL are served from cache. A user visiting https://example.com?myvariable=that
would generate a different cache key, and thus the server would cache the page separately, even if the final page result were the same.
If the content on the page is the same, it makes sense to ignore the myvariable
parameter as far as the server-side cache is concerned. If ignored, the same cached content would be used for both of these URLs, without the need to cache them separately.
Including UTM Variables in the Cache Key
Since UTM variables are intended to be processed on the client side, they're ignored by default. If needed, they can be included with the following steps:
- Start by logging into the Atomic control panel.
- Next, navigate to your app list by clicking on Apps within the left side menu.
- From your app listing page, locate the app that you want to make changes to, then click on the settings icon to the right of the app's name.
- Now that you're inside of the app's details view, click on the ARES tab to access your app's ARES gateway settings.
- On the left side of the ARES section, click on Cache Keys to access your cache key configuration.
- Inside the Parameters to Include in Cache Key section, you'll see a listing of the parameters that Pagely ignores from the cache key by default.
To include a variable, simply toggle the switch to the left of it.
(Note: it's generally a bad practice to be using UTM variables on the server side. Enabling any of these can have negative impacts on your site's performance. Only enable these out of absolute necessity.) - After your variables are included, don't forget to click the Save button.
- Finally, you'll need to deploy your changes for them to become active on your site. To do so, click on the Deploy Changes button.
Excluding Variables from the Cache Key
If you're passing custom variables within your URLs that are only processed by JavaScript or other client-side methods, excluding these query string variables can improve your cache hit rate.
To exclude a variable from your cache key, follow these steps:
- Start by logging into the Atomic control panel.
- Next, access your app list by clicking on Apps on the left side menu.
- From here, locate the app that you want to make changes to, then click on the settings icon to the right of it.
- Once inside your app's details page, click on the ARES tab to access the ARES gateway settings.
- Next, click on Cache Keys.
- To exclude a parameter from the cache key, scroll down to the Custom Parameters to Exclude from Cache Key section and enter the parameter into the field.
- If you need to add multiple parameters to be ignored, you can click on the + symbol on the right to add an additional field.
- After adding your parameters, don't forget to click on the Save button to save your changes.
- Finally, to make your changes active, click on the Deploy Changes button.