JosephSilber / page-cache

Caches responses as static files on disk for lightning fast page loads.
MIT License
1.21k stars 118 forks source link

[Question] Multiple versions of the page? #86

Closed Marchiuzzz closed 3 years ago

Marchiuzzz commented 3 years ago

We have a website which is slightly different for each user (I guess this violates the condition that a page has to be static in order for this package to work). But is there a way to configure this so that each user would get their own sub-folder and then pages cached there, for each user individually? Or does that just sound overall stupid?

JosephSilber commented 3 years ago

Since files are cached on - and served from - disk, your app is never booted up. That's why responses are so blazing fast.

Since your app isn't booted, we're not even aware of who the logged-in user is.


If you need to have the page be different for each user, you can have a follow-up JS call that would fetch that change.

If that doesn't work for you (either because you don't want to rely on JS, or because the changes to the page are too big), then you should be using a different caching mechanism; one that boots your app and handles fetching data from the cache from within your app.

Marchiuzzz commented 3 years ago

@JosephSilber Thanks for a detailed answer and suggestion. It does indeed make more sense to cache data instead of the whole rendered view.