Skip to content

How to clean the caches at your ShimmerCat Edges

ShimmerCat caches static assets at the edges using two different caching classes. Depending on configuration, they are either cached as normal files (NF) or as generated assets (GA).

For assets cached as normal files, the best way to notify the edges of new versions of the files is through the so called "changelists". For generated assets, the most straightforward way to notify the edges of new content versions is by using new query strings. Each of these mechanisms works only in its caching class: changelists for normal files, new query strings for generated assets.

But there is a third mechanism which works for both, namely, using our API to evict entries from the edge caches. This document explains how to use that mechanism.

Clean cache with the API

Executing the command below results in an HTTP request to our API server. The request triggers a remote task for cleaning cache entries in all the edges that serve the domain.

curl \
     -X POST \
     https://accelerator.shimmercat.com/presentation-api/v1/clear-shimmercat-
  cache/www.example.com/ \
     -H 'Authorization: Token TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT' \
     -H 'Content-type: application/json' \
     -d '{"url_path_patterns": ["images jpg"]}'

Fields to replace

  • www.example.com Write here which domain you want to clear the cache
    from. This must be one of the domains in your ShimmerCat Accelerator account.
  • TTTT.... Write here you API token, which you should have
    received when subscribing to our service or via support channels.
  • "images jpg" Write here a selector for the cache entries you want to
    delete. More details about selectors below.

Selector for cache entries

By selectors, we mean the expression after “url_path_patterns”. In the initial example we wrote [“image jpeg”], and this simple string will wipe all JPEG images from the caches, so that the edges fetch fresh versions of them. By changing the string, it’s possible to target different classes of resources. There is a logic to the expressions, but it’s easier to start with some utility examples.

Cheat sheet

I want to... Selector expression
Delete a specific resource, e.g. "/js/general.js?181122" Give a single string with the elements of the URL which are letters and numbers, separated by space, without any sign separators. Note that if the resource is being pulled as a file, the query string component is not indexed, so you shouldn’t use it. Works for generated assets: ["js general js 181122"]. Works for both generated and file assets, but it won’t discriminate resource versions given via a query string: ["js general js"]
Delete all images Give a list of image mime types that you use across your site, again without punctuation marks: ["image jpeg", "image png", "image gif", ... ] or use boolean syntax: ["image AND (jpeg OR png)"]. If you are confident that all your image mime types contain the word “image”, then you can also use this: ["mime_type: image"]
Delete all resources that start with a particular URL path, e.g. everything that starts with "/js/default/" Use a “^” at the start of the expression, like this: ["^ js default"]. It’s possible to be more specific by indicating that the we are interested in matching only relative paths: ["relpath: ^ js + default"].

What is this selector syntax?

Each ShimmerCat deployment maintains a separate full-text search index of all cached entries of each domain, using SQLite’s FT5 FTS engine. The selectors for cache entries are simply FT5 arguments to the MATCH filter keyword, over a full-text search table with two columns: relpath and mime_type . You can learn everything about this query language using the official SQLite3 documentation for it.

Reporting issues

If you have any questions or feedback, don't hesitate to contact us at ops@shimmercat.com or through our ticket system.