-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Grav cache is not working using modular templates and parameters #1211
Comments
Ok, so this took me a while to track down and I had a lot of trouble recreating this on my own, but it turns out I was doing things one way, and you were doing things another. Basically this all worked fine with my setup because I created a separate However, your example site had the clue. You had multilang on, but were only using a single non-language specific I fixed this by ensuring the cache id for all pages takes into account the current language. This means that each page will be cached independently for each language even if it's the same actual So that should fix your translation in modular content issue. In action: https://gfycat.com/EqualSimpleArcherfish Regarding the second issue you mentioned about the query parameter. This is just a caveat of how modular pages work. To summarize. A modular page is built from various modular sub-pages. For each subpage, the content is processed against the corresponding modular twig, and the result of this rendered output, it saved as the content of that subpage. This is then cached. Therefore any 'logic' you put in that modular subpage's twig template, is going to only be processed the first time through, after that the content is already rendered and cached. This is the point of modular pages. If you want a particular modular sub-page to process the Twig each time, then you must disable the cache on that particular modular sub-page. That means the content will be reprocessed against the twig each time. If you put your query param check in the top-level modular page's twig, it will run each time and work correctly. This is beacause for a non-modular page (ie one that is not prefixed by That all said, you say you are seeing this on regular pages also, not just modular pages. But i am not seeing it that way. It works for me when i put the logic in a regular twig file:
Then i can request in action: |
Reopen if you continue to have issues.. But should be good now. |
BTW, I have a Pull Request that provides the ability for modular pages to cache content but not the twig. This will allow you to have real logic in modular pages. This has long been asked about as it comes up quite frequently when doing more dynamic stuff. If you want give it a try. You can keep it disabled, and just enable it on modular sub-pages that need it. |
@rhukster Huge thanks, it look like it's working properly. Thanks a lot for taking the time to answer properly. I removed the For the query parameters, because of your explanations, I realise I wasn't using Grav properly:
Since I'm now using for each page, a different template, the query issue is gone. Thanks, |
with the new |
Yes but it means this sub-modular will not be cached and I would like to avoid that so I will also avoid parameters as much as possible :) Thanks anyway! 👍 |
Hi,
I need to use the cache of Grav as I have more than 200 modular pages in my app. If I don't have cache, the page response time from the server is higher than 1500ms. (https://www.busuu.com)
Grav is not working with the cache enabled (
cache:enabled:true
insystem.yaml
) when having multiple languages variations like/es
,/fr
, etc...The issue is mostly related to modular templates.
Here is how to replicate:
|t
.When switching from language, the string is always the first loaded string. If you have lang variations then the language displayed between two lang variations is hard cached. Basically a given String will be displayed in Spanish on both
/es
and/fr
versions. Example: http://imgur.com/a/KoehdThe second issue is regarding parameters query and it's not related to modular:
/en/register?learning=es
the learning param will bees
/en/register?learning=fr
the learning param will remaines
Even if the page is not modular, the issue is visible with a normal page.
Here is a small GIF to show the issue: http://imgur.com/a/Koehd
Here is a Grav Instance to replicate the issue: https://www.dropbox.com/s/y4pxfyuirjsio0n/grav.zip?dl=0
Here is the thread in the forum: https://getgrav.org/forum#!/general:cache-is-too-strong-lang
And I can't add
cache_enable: false
on my modular. I have more than 200 pages that are modular with inside 5 to 8 modulars ( so more than 1200 modulars ). So it will end up finally to have the same as not having any cache at all.Thanks,
Seb
The text was updated successfully, but these errors were encountered: