Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[TwigBundle] Allow to exclude files and directories on cache warmup#34416

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
yceruto wants to merge1 commit intosymfony:masterfromyceruto:twig_cache_finder

Conversation

@yceruto
Copy link
Member

@ycerutoyceruto commentedNov 16, 2019
edited
Loading

QA
Branch?5.1
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#34142
LicenseMIT
Doc PR-

So you can put any file/directory (not related to Twig's templates) intemplates/ dir and configure which files/directories can or cannot be warmed up, increasing the performance on 'cache:clear' (sometimes impossible).

Example of configurations:

twig:    # include all *.twig files only    cache_pattern_files: '*.twig'    cache_pattern_files: '/\.twig$/' # same as above    # include multiple files/extensions    cache_pattern_files: ['*.twig', '*.svg'] # can be done in one regex too        # exclude all *.png files only    cache_pattern_files: '/.*(?<!\.png)$/'    # exclude directory paths    cache_exclude_paths: ['node_modules', '...'] # 'bundles' will always be excluded

Backward Compatibility

Unaffected! By default all files for all Twig's paths will be warmed up as well as the'bundles' directory will be excluded even if it's not added to thecache_exclude_paths option by the user.

It's up to you to decide the structure of your template directories and which files/dirs should or shouldn't be cached.

Replacement of#34321
Also related to#28282

wdyt?

fritzmg and cesurapp reacted with thumbs up emoji
@ycerutoyceruto added this to thenext milestoneNov 16, 2019
@ycerutoyceruto changed the title[TwigBundle] Allow to configure the files and directories to warmup on cache[TwigBundle] Allow to exclude files and directories on cache warmupNov 16, 2019
@yceruto
Copy link
MemberAuthor

yceruto commentedNov 16, 2019
edited
Loading

Note that I'm usingcache_pattern_files option for both purposes (include/exclude files), but we could separate it into two optionscache_include_files andcache_exclude_files if you think it's more clear, calling to$finder->names() and$finder->notNames() methods respectively.

@fabpot
Copy link
Member

I'm always very skeptical when we add new settings and when they are global.

Thetemplates/ directory is, well, for templates only. If people store something else, that's their responsibility, not ours. I'm 👎 for anything that allow people to store everything under thetemplates directory.

nicolas-grekas, OskarStark, derrabus, and yceruto reacted with thumbs up emoji

@m-vo
Copy link
Contributor

m-vo commentedNov 17, 2019
edited
Loading

But what's with things like this?

<h1class="logo">{{include('@Twig/images/symfony-logo.svg') }} Symfony Exception</h1>

In a bare Symfony 4 installation with only twig installed I already get 28 templates and 64 'other' files including php templates and images.

Details: list of loaded templates during cache warmup
"base.html.twig""@Framework/FormTable/hidden_row.html.php""@Framework/FormTable/button_row.html.php""@Framework/FormTable/form_widget_compound.html.php""@Framework/FormTable/form_row.html.php""@Framework/Form/form_rows.html.php""@Framework/Form/color_widget.html.php""@Framework/Form/integer_widget.html.php""@Framework/Form/form_widget_simple.html.php""@Framework/Form/button_widget.html.php""@Framework/Form/repeated_row.html.php""@Framework/Form/button_attributes.html.php""@Framework/Form/hidden_widget.html.php""@Framework/Form/money_widget.html.php""@Framework/Form/form_start.html.php""@Framework/Form/datetime_widget.html.php""@Framework/Form/form_rest.html.php""@Framework/Form/reset_widget.html.php""@Framework/Form/form_errors.html.php""@Framework/Form/form_enctype.html.php""@Framework/Form/form.html.php""@Framework/Form/form_end.html.php""@Framework/Form/widget_container_attributes.html.php""@Framework/Form/search_widget.html.php""@Framework/Form/widget_attributes.html.php""@Framework/Form/choice_attributes.html.php""@Framework/Form/hidden_row.html.php""@Framework/Form/email_widget.html.php""@Framework/Form/choice_widget_options.html.php""@Framework/Form/checkbox_widget.html.php""@Framework/Form/choice_widget.html.php""@Framework/Form/range_widget.html.php""@Framework/Form/attributes.html.php""@Framework/Form/url_widget.html.php""@Framework/Form/button_row.html.php""@Framework/Form/form_widget.html.php""@Framework/Form/textarea_widget.html.php""@Framework/Form/radio_widget.html.php""@Framework/Form/tel_widget.html.php""@Framework/Form/choice_options.html.php""@Framework/Form/collection_widget.html.php""@Framework/Form/form_help.html.php""@Framework/Form/choice_widget_expanded.html.php""@Framework/Form/button_label.html.php""@Framework/Form/submit_widget.html.php""@Framework/Form/date_widget.html.php""@Framework/Form/number_widget.html.php""@Framework/Form/form_label.html.php""@Framework/Form/percent_widget.html.php""@Framework/Form/container_attributes.html.php""@Framework/Form/choice_widget_collapsed.html.php""@Framework/Form/time_widget.html.php""@Framework/Form/form_widget_compound.html.php""@Framework/Form/form_row.html.php""@Framework/Form/password_widget.html.php""@Twig/base_js.html.twig""@Twig/Exception/exception_full.html.twig""@Twig/Exception/exception.css.twig""@Twig/Exception/error.html.twig""@Twig/Exception/traces_text.html.twig""@Twig/Exception/error.js.twig""@Twig/Exception/error.txt.twig""@Twig/Exception/exception.html.twig""@Twig/Exception/trace.txt.twig""@Twig/Exception/traces.html.twig""@Twig/Exception/exception.json.twig""@Twig/Exception/trace.html.twig""@Twig/Exception/exception.atom.twig""@Twig/Exception/traces.txt.twig""@Twig/Exception/exception.rdf.twig""@Twig/Exception/exception.js.twig""@Twig/Exception/exception.txt.twig""@Twig/Exception/error.css.twig""@Twig/Exception/exception.xml.twig""@Twig/Exception/error.atom.twig""@Twig/Exception/traces.xml.twig""@Twig/Exception/error.json.twig""@Twig/Exception/logs.html.twig""@Twig/Exception/error.rdf.twig""@Twig/Exception/error.xml.twig""@Twig/exception.css.twig""@Twig/layout.html.twig""@Twig/images/icon-minus-square.svg""@Twig/images/favicon.png.base64""@Twig/images/icon-plus-square.svg""@Twig/images/symfony-ghost.svg""@Twig/images/icon-book.svg""@Twig/images/chevron-right.svg""@Twig/images/icon-plus-square-o.svg""@Twig/images/icon-minus-square-o.svg""@Twig/images/icon-support.svg""@Twig/images/symfony-logo.svg"

In this case filtering for.twig would work but that's not guaranteed as long as using other extensions is explicitly allowed/not deprecated. (also see#34142 (comment))

fritzmg reacted with thumbs up emoji

@yceruto
Copy link
MemberAuthor

Fair enough 👍

@stof
Copy link
Member

@m-vo in this case, this fileis a template (include includes templates)

@m-vo
Copy link
Contributor

You mean a template without any placeholders? That's an asset imho and that should not need to be parsed.

fritzmg reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

5.1

Development

Successfully merging this pull request may close these issues.

[TwigBundle] TemplateCacheWarmer processes non-template files

6 participants

@yceruto@fabpot@m-vo@stof@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp