-
Notifications
You must be signed in to change notification settings - Fork 1
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
Assets not loading with twig cache enabled #1
Comments
Hi, @filippomasoni Do you have at the bottom of your base template (before {{ assets.js('bottom')|raw }} |
Hmm... I suspect this might be related to how modular pages are cached. I tested on a non-modular page 🤔 |
Can reproduce in modular page |
Asked some questions and searched a bit and found this old comment from the Grav developer himself and it kinda makes sense. Just checked and So basically what happens with modular, as I understand it, all modules are merged and cached as one modular page and next time it renders, Twig extension which renders Photoswipe is never called. Disabling Twig cache makes it render after the content is cached and that makes assets render. Sorry, but it's a Won't fix from where I stand 🙂 |
BTW, you could move |
Thank you for actually putting the time in and researching the problem. I actually find that old comment from the Grav dev very important as it explains the best way to handle things like this maintaining maximum cache performance possible. I'm glad that's exactly what I previously did without knowing the details, I just did some trial and error. I'm glad we now understand why it happens and hopefully will be helpful to others. I do actually want to have multiple galleries on my modular page and I have my gallery.html.twig template including photoswipe and giving it a dynamic ID based on the page folder name. I've done the same before with another gallery plugin. At this point, I think the best solution for people that want to use photoswipe on modular pages, is to have a default Thank you again and have a great day |
It works perfectly with cache disables or with “never cache twig” enabled on the gallery modular page, otherwise at the second refresh photoswipe css and js are not loaded anymore.
I’m on the latest stable Grav version with admin and other plugins.
I’m including css and js from the base theme like this:
I tried on a different Grav install (v1.7.10) as well and it’s doing the same.
The text was updated successfully, but these errors were encountered: