Cachebusting Methods Using API Checks

Browser caching is a vital part of efficient webpage loading and communications, allowing for local storage of data that promotes faster loading of webpages from the user perspective.

However, from a monitoring perspective, caching can be problematic since the stored data can mean a webpage is outdated and the correct content is not being monitored or checked. Cachebusting methods ensure that the page is monitored with a fresh cache each time and that stored data does not interfere with the monitoring process.

API checks offer a simple solution to cachebusting that can be easily implemented using a variable that generates a random number and adds it to the end of the URL.

Do to this, create a Set variable name from current date and time step at the beginning of the check with an Offset of 0 and a Time format of %s:

Then create a step to check the desired URL with the variable with the following appended:

?no-cache=$ts$

Where $ts$ is the variable created in the first step. Finally, set a validation rule to ensure that the HTTP status code should be 200:

The variable generates a numerical string according to the current time in seconds, which effectively functions as a number generator to ensure that the cache is being bypassed:

 

Cachebusting in HTTPS Checks

Cachebusting is also simple to implement for HTTPS checks using Cache-Control Headers under the HTTP Headers field in Optional settings.. You can use headers like Cache-Control: no-cache (which will check the server to see if data has changed before serving the cached data) or Cache-Control: no-store (which caches no data and may be used when monitoring sensitive data that should not be stored at all).

This instructs the CDN and any intermediary caches to fetch a fresh copy if necessary from the origin server, ensuring that a cached version (or outdated version) is not being fetched for monitoring.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.

Have more questions?
Submit a request
Share it, if you like it.