JosephSilber / page-cache

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

Caches also saves data in the navbar #112

Open Askancy opened 1 year ago

Askancy commented 1 year ago

The caching system works properly, however, it happens that if caching is stored with me as the user, visitors who visit the page end up with my name as the logged-in user in the navbar. How can I avoid having items cached that should only be seen by logged-in users?

jonathonbyrdziak commented 1 year ago

What you're trying to do is probably outside the scope of this caching extension at the moment. However, here's something you can do to begin accomplishing this:

Load your sensitive data through ajax. This caching extension is only going to cache the response from specific controllers. so If you're using an ajax loading system to populate certain datasets, then the core of the page gets cached and your sensitive content is loaded via ajax (not a cached route)

tvbeek commented 11 months ago

Personal I only use the middleware on public routes (that doesn't have any user information visible) If the current user is the only different part it can be an option to use the ajax way as described by @jonathonbyrdziak

Else I think it is more useful to cache parts of your response and not the whole page (but that is out of scope for this package).