Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

Shortcode section cache problem

Started by Filippo Masoni 6 years ago · 2 replies · 579 views
6 years ago

Hi, I recently started to use the shortcode plugin to create sections of content in my pages, I have a template that displays that section into a different element. All of the pages that use that template display the section of the first page where it's defined and ignores all the others because it caches the first variable. If I disable caching in Grav then it works. Is there a way to make the template only pick up the section defined on the same page without disabling caching?

6 years ago

In the blog post about the upcoming version 1.7 I read that it will feature a finer granulated coaching mechanism. In the mean time you could try using cache_enabled: false in the specific page frontmatter to disable the cache on a per page basis.

6 years ago

I read the blog post a while ago, we'll see how that'll work for my situation.
Thanks for the tip, I'll try disabling on a per page basis, at least I can cache the others, but I'm using shortcode for product pages, so it's actually the biggest part of the site.

I still don't understand why it does that though. Is that the correct functionality? section variables are global and when cached it just picks up the first one? Or is that a bug?
EDIT:
I just read this on the docs about disabling cache.
"An example of this is when you are using dynamic Twig variables in your content." Does that mean shortcode is setting a dynamic twig variable?

Also since we're talking about cache, I would like to understand better how it works. If disabled does that mean every page load it has to recreate images as well or it only applies to twig and markdown?

last edited 05/08/20 by Filippo Masoni

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 44 1 week ago
Plugins · by Xavier, 4 weeks ago
2 54 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1181 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 48 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 73 2 months ago