Skip to content
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

Display additional page content for authorized users only - with caching enabled #2384

Open
otahirs opened this issue Feb 20, 2019 · 3 comments
Assignees
Labels

Comments

@otahirs
Copy link

otahirs commented Feb 20, 2019

I am familiar with displaying additional content for certain users by using

{% if (authorize(['site.foo'])) %}
        <h1>Hello World!<h2>
{% endif %}

However when twig caching is enabled, this approach does not work, as the same last cached version of the page is showed to both authorized and normal users.

How should I tackle this issue or is it possible to exclude certain parts of a page from caching?

PS: I temporally use a "never cache twig" option, but the TTFB (time to first byte) is more than doubled.

@otahirs otahirs changed the title display additional page content for authorized users only - with caching enabled Display additional page content for authorized users only - with caching enabled Feb 20, 2019
@mahagr
Copy link
Member

mahagr commented Feb 20, 2019

Right now there's no other option than to disable caching from the whole page. I have plans to allow dynamic sections inside a cached page, but it will still take some time to get everything that is required to make this to work in place. See: #1934

@mahagr mahagr self-assigned this Dec 13, 2019
@mahagr
Copy link
Member

mahagr commented Mar 9, 2021

This should now work better.

@mahagr mahagr closed this as completed Mar 9, 2021
@mahagr
Copy link
Member

mahagr commented Mar 9, 2021

I take that back, looks like the content is inside twig.

@mahagr mahagr reopened this Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants