getgrav / grav-premium-issues

Official Grav Premium Issues repository to report problems or ask questions regarding the Premium products offered.
https://getgrav.org/premium
7 stars 2 forks source link

[site-toolbox] warm-cache for login proteced sites #354

Closed alangner closed 1 year ago

alangner commented 1 year ago

When I trigger a warm cache run, e.g. via cli (bin/plugin warm-cache warm https://mysite.com/sitemap.json), I see in the logs that many pages are called correctly. However, I have a lot of pages that are only visible for users who are logged in. In these cases only the login page is called multiple times: "200: https://mysite.com/login"

I would like to warm the cache for these pages as well. Is this possible with this plugin?

Grav v1.7.39.4 Warm Cache v2.0.3

rhukster commented 1 year ago

It's not possible to warm the cache of a protected page because the warm cache uses the sitemap and is acessing the pages like any un-authorized user.

Also, pages that require user access usually have some level of personalization (think profile page, or perhaps a list of paid features). These are very indivualized and usually rely on logic that gets data back for that specific user. These are not going to benefit from caching anyway, as they can't be cached in the traditional sense, they need to always be dynamic and specific to the user.

If you had fairly static content behind a paywall, you could theoretically create a plugin that took a user-agent header tag and just gave that specific warm cache user-agent access. That's one of the reasons the warm cache has a configurable user-agent field. But this would require a custom plugin and really is beyond the regular every day use of warm-cache. But it is possible!