Skip to content

Ability to "reset" cache of rendered files automatically in Twig #90

Closed
@weaverryan

Description

@weaverryan

Related #87

When you encore_entry_link_tags() or encore_entry_script_tags() tags, the bundle "remembers" which CSS and JS files have been rendered and avoids rendering them again. This is by design: it allows you to render multiple "entries" on the same page and avoid link/script tags for the same CSS & JS files (due to code splitting).

But, this has some nasty side effects. One practical one is sending emails and using these functions to import your CSS. If you have Messenger installed, each Email is technically rendered twice - and the second (real) email will contain no CSS link tags. The problem is probably worse when sending emails through the queue - as I think once a worker has sent one email, the rest won't contain CSS link tags.

The best solution would be to reset "automatically" the cache after a "main" Twig rendering (e.g. a call to$twig->render()) but no such concept currently exists in Twig.

A more immediate solution may be to allow users to "opt out" of the cache via some argument to encore_entry_link_tags().

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