Skip to content

[Twig] [TwigBundle] Describe the new behaviour of twig.cache config #20951

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

Merged
merged 1 commit into from
May 12, 2025

Conversation

Okhoshi
Copy link
Contributor

@Okhoshi Okhoshi commented May 10, 2025

Update the description of the twig.cache config to follow the changes implemented in symfony/symfony#54384.

Fixes #20948

cc @alexandre-daubois

@carsonbot carsonbot added this to the 7.3 milestone May 10, 2025
Signed-off-by: Quentin Devos <4972091+Okhoshi@users.noreply.github.com>
@carsonbot carsonbot changed the title [TwigBundle] Describe the new behaviour of twig.cache config [Twig] [TwigBundle] Describe the new behaviour of twig.cache config May 12, 2025
@javiereguiluz javiereguiluz merged commit f6e6a8c into symfony:7.3 May 12, 2025
3 checks passed
@javiereguiluz
Copy link
Member

Thanks Quentin for this contribution!

I did some minor rewords while merging, but I left your core contribution intact.


I find the new docs a bit confusing so I'm asking something to you.

Is the following current explanation:

When set to ``true``, the cache is stored in ``%kernel.cache_dir%/twig`` by default.
However, if ``auto_reload`` is disabled and ``%kernel.build_dir%`` differs from
``%kernel.cache_dir%``, the cache will be stored in ``%kernel.build_dir%/twig`` instead.

Equivalent to this simplified version?

When set to ``true``, the cache is stored in ``%kernel.cache_dir%/twig`` by default.
However, if ``auto_reload`` is disabled the cache will be stored in
``%kernel.build_dir%/twig`` instead.

I mean:

  • If auto_reload is disabled:
    • If build_dir and cache_dir are different, then build_dir is used
    • If build_dir and cache_dir are the same, then cache_dir is used. BUT, if they are the same, we're using build_dir
    • So, we always use build_dir when auto_reload is disabled, right?

Maybe I'm missing something here.

@Okhoshi
Copy link
Contributor Author

Okhoshi commented May 12, 2025

@javiereguiluz It's indeed a bit confusing, because the setup is a bit more convoluted, but for the sake of simplicity, not all the details are described in the doc.

There's actually a slight difference when the cache is set to build_dir or cache_dir (other than the directory itself).
If build_dir is used, we construct a two layers cache with a read-only layer pointing to build_dir and a read/write opportunistic cache pointing to cache_dir.
If cache_dir is used, we set up a simple one-layer cache on cache_dir.

Hence why the distinction, even if you are actually right with the simplified version.

Happy to discuss any improvements we can make on the doc for this 👍

@Okhoshi Okhoshi deleted the ticket_20948 branch May 12, 2025 07:03
@javiereguiluz
Copy link
Member

Thanks for the detailed explanation 🙏 I think you are right that it's better to not mention all these internal details in the docs.

Also, let's wait until Symfony uses build_dir for everything and it's "fully read-only" to see if we can tweak many docs at once related to that if we think it's needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TwigBundle] Use kernel.build_dir to store the templates known at bui…
5 participants