Skip to content

Developers · Best Practices

Static Cache

Last updated 2 November 2026

Static cache involves creating a static response that bypasses the entire server side, including the authorization process. Completely bypassing the application server makes this approach comparable to server-side rendering and offers faster performance.

However, the usage of static cache is limited. While it's ideal for achieving high speed on non-authenticated user pages like the home page, it is rarely applicable in other scenarios. For instance, using a static cache for a dashboard is not feasible since authentication is required for accessing personalized user data.

Use Cases

Static cache is an excellent choice for creating a sitemap that needs updating at most once a day. Developers commonly utilize it for JSON APIs that prioritize fast response times.

This caching method is particularly suitable when the data being served remains relatively unchanged and is not influenced by nor depends on the specific user requesting the information.

Example

For example, if you were to build a currency exchange rates API, you might want to fetch data from the database at most once a minute, not more often.

app/views/pages/currencies.json.liquid

---
static_cache:
  expire: 60 # response will be cached for 60 seconds (or 1 minute)
---
{% assign rates = {} %}
{% assign rates.PLN = 10 | random_string %}
{% assign rates.USD = 10 | random_string %}
{% assign rates.CHF = 10 | random_string %}
{% assign rates.AUD = 10 | random_string %}
{% assign rates.JPY = 10 | random_string %}
{{ rates | json }}

Note

It is important to note that Insites' load balancers distribute requests to multiple servers, each with its own separate cache. As a result, you may experience varying results depending on whether you hit a server with warm cache (data already in the cache) or cold cache (no cached data).