-
-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nocache: Always fallback to partial - no placeholder text #6744
Comments
You shouldn't have to do that. That's what the |
I understand that but there is a problem with this concept when using custom routes - especially ones with forms and authentication logic. As explained, I have a header partial that is used in custom authentication pages (login, reset password, dashboard etc.). This same header is also used in my Statamic pages, on which static caching is applied. So I have two bad choices in my case:
What I am suggesting is that the nocache tag simply falls back to the partial when the caching middleware is not applied, instead of outputting the "NO_CACHE_PLACEHOLDER" text, which I don't think anyone would want to see. |
The challenge is that by the time the tag is run it's too late, and it doesn't know about the middleware. And the placeholder has to be there, in order to make the whole thing work. Interesting problem. |
Hmm yes, I have probably underestimated the complexity of this one. I have no idea how nocache works. Perhaps the sequence can be changed so that it is aware of the middleware. Adding the statamic.web middleware to all routes works fine. It just seems wrong to add it to pages where I don't want any static caching at all (e.g. login, register). Maybe I could temporarily workaround with something like this:
|
You can always go the other way if you want, don't use static caching but do use the |
Didn't see this issue when creating #7820, sorry. Maybe possible fix in the comments and example repo. |
Bug description
I think the @nocache directive / tag should be updated to output the partial when the statamic.web middleware is not applied, if possible. Let me explain my reasons:
I have a custom auth system and guard from my front-end. The site header contains a menu that differs based on your authentication status. For this reason I am applying @nocache to the partial.
header.blade.php
partials/nav-main.blade.php
The problem:
If I don't add the statamic.web middleware to my auth routes (which contain this header partial) then I will see NO_CACHE_PLACEHOLDER.
If I do add the statamic.web middleware to my auth routes then the @nocache tag works, but then I have to add a lot of auth routes (login, register, password reset, etc.) to the static cache invalidation exclusions. This feels unnecessarily complicated.
Solution:
Just output the partial (as would happen using include()) when static caching is not enabled or not available (no statamic.web middleware) is on the current route.
Thanks!
How to reproduce
Use @nocache directive / tag on custom auth routes.
Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
No response
Additional details
No response
The text was updated successfully, but these errors were encountered: