I don't understand what there is to cache in a web framework.
Is it to cache rendered pages without dynamic content?
If so, I think it is better to let a CDN handle that. Instead of the server that runs the web application.
What am I missing?
I don't understand what there is to cache in a web framework.
Is it to cache rendered pages without dynamic content?
If so, I think it is better to let a CDN handle that. Instead of the server that runs the web application.
What am I missing?
But you can cache other things that are not the entire page itself:
- database queries
- user sessions
- api calls
- page fragment
- function memoization
What's more, cache backends have the ability to expire things, which can be helpful for all sort of stuff.
E.g. results from external services, calculations, anything that an application might want to cache.
Am working on a somewhat large Django system, and there is a ton of different things we cache in Redis.
Also HTML template results as another comment mentioned, but mostly something else entirely, related to the application logic.
HTML, not assets.
Some such setups (like one I wrote for a busy Drupal newspaper site way back when) can support clearing relevant cache entries on DB write, so you're essentially never serving stale data, but can save _substantial_ DB load - and possibly webserver load too, depending on how computationally intensive the HTML generation is.
What's annoying with Python though is how hard it is to just cache stuff in some dict or other data structure, since the GIL basically forces each request to have it's separate process (instead of separate thread). So non-trivial to share some state application wide without having to store it outside the application.
Of course a shared cache is sensible when there are multiple nodes running the application. But not everything needs a global cache either, or maybe the point of the cache was exactly to avoid a round trip to something else.