Static Cache

Last updated on June 26, 2024.

Static cache involves creating a static response that bypasses the entire server side, including the authorisation 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 personalised user data.

Use Cases

Static cache is an excellent choice for creating a sitemap that requires updating no more than once a day. Developers commonly utilise it for JSON APIs that prioritise 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

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 (previously cached data) or cold cache (no cached data).

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.