Skip to content

Add a no-op cache tag #245

@bcdickinson

Description

@bcdickinson

Is your proposal related to a problem?

Cache-related template tag's like Django's {% cache %} and Wagtail's {% wagtailcache %} and {% wagtailpagecache %} work by attempting to render a cached fragment, falling back to rendering the child nodes and storing the result in the cache.

When viewing patterns in the pattern library, particularly during local development, this is not what you want. You want to be able to instantly view changes made to the template. Additionally, context required to generate cache keys, such as page.cache_key in the case of {% wagtailpagecache %} may not be present in the pattern library context.

Describe the solution you'd like

I propose the DPL should have a no-op tag that unconditionally renders it's children and the ability to specify by name the tags that should be replaced with the no-op tag implementation in pattern library contexts. Config for this might look something like the following:

PATTERN_LIBRARY = {
    ...,
    "NOOP_CACHE_TAG_NAMES": ["cache", "wagtailcache", "wagtailpagecache"],
}

Maybe ["cache"] should be the default value for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions