Our new query caching system is a complete rebuild of our old system. If you were using our old caching system, read on for an explanation of how they differ. If you were not using the old SQL caching system, you can head straight to the updated docs to find out how the new system works.
What's the TLDR of the new caching system?
With our new caching system, any time a SQL cell is run, Hex checks if the same query has been run recently. If it has, Hex pulls results from its cache, rather than sending the query to your warehouse.
When developing logic: Results from the cache are clearly shown in on the SQL cell, with a button to rerun the query without cached results, should you need to refresh the results. There’s also a button to rerun an entire project without using cached results.
In published apps: When an app uses results from the cache, it’s indicated on the published app. An app user can choose to rerun the app without cached results to get fresher data.
By default, results from the cache will be used if the same query has been run within the last 60 minutes. Admins can adjust this default for their workspace, with separate timeouts for developing logic, and published apps.
Further, editors can choose to set their own timeouts per project.
For more information, head to the docs.
What are the main differences between this and the old caching system?
| Old caching system | New caching system |
|---|
| Had to be turned on per cell | On by default, with a workspace cache timeout set by admins, which can be further configured per project by editors. |
| Cache entries were valid until the next scheduled run, or next app load (depending on configuration). | Configurable cache timeout per project (e.g. 60 minutes) with separate settings for logic and app sessions. Additionally can use the next scheduled run as the expiry. |
| Cache entries could not be shared between projects. | We now check entries based on query text and data connection details, allowing us to share cache entries between projects. This is useful when projects have been duplicated, or you are using components. |
| Confusing UI | More intuitive UI |
What happened to the old SQL caching system?
The previous SQL caching system has been fully deprecated: our new system is more performant, and easier to understand.
Any projects that leveraged SQL caching in combination with scheduled runs have been migrated to use the equivalent settings in our new system:
My published apps that loaded fresh data now have results up to an hour old. How can I change this?
The default cache timeout for workspaces is 60 minutes. This means that any published app that is set to run when an user opens the app may pull results from the cache that are up to 60 minutes old, whereas previously they would have always queried the warehouse.
If you have individual apps that should show fresher data, you can update the cache timeouts from the Environments panel of your project. Note: we recommend that you at least keep a timeout of a few minutes, rather than fully disabling the caching. You will need to republish the app for this change to take effect.
An admin can also adjust the workspace default to a shorter timeout, which will update any project that does not have a custom timeout configured.
How do these changes interact with the "Cache default state" settings?
Previously, we used the word "cache" to describe two distinct Hex features:
- SQL caching: The ability to fetch results of a SQL query from a cache, rather than send the query to the warehouse.
- App caching (or Cache default state): The ability to view the output of a previous run when opening a published app. In this context, the "output" is limited to the front-end output (e.g. a chart visual, but not the data powering it)
While both of these features were built to make Hex faster, they are somewhat distinct in how they work, and the shared name made this confusing.
So, we redesigned the UI for cache default state (see below), but have not changed how this feature works.