cache with dynamic pages -- [Question Asked]

Issue

I am currently developing a WEB site on symfony 6 and during production testing I have a problem with the TWIG cache.
Indeed, my site includes a page editing feature. So when rendering the first time, the page is rendered correctly. However, if the editor then modifies the page, and I return to the page is still the old version. Is there a way to integrate a cache check, for example it looks at the hash of the loaded template has not changed?

How is the page loaded:

{% extends 'base.html.twig' %}

{% block title %}
    {{project.libelle}}
{% endblock %}
{% block content %}
    <div class="content">
        {{ckRender(include("dynamique/" ~ project.page.filename))}}
    </div>
{% endblock %}

Thank you for your help

Answer we found from sources

Thank you DarkBee.

I had seen the forum but not necessarily read in detail. With a bit of research here is what we can do (for those who are interested):

There are two possibilities:

  • the best : modify the configuration file “/config/packages/twig.yand” and add “auto_reload: true”.
  • the other, add instead “cache: false”

With the first method, twig checks otherwise the files have been modified (light cost for performance), in the second twig always regenerates the template, so no cache (high cost for performance).

Answered By – erloup

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Posted in PHP

Who we are?

We are team of software engineers in multiple domains like Programming and coding, Fundamentals of computer science, Design and architecture, Algorithms and data structures, Information analysis, Debugging software and Testing software. We are working on Systems developer and application developer. We are curious, methodical, rational, analytical, and logical. Some of us are also conventional, meaning we're conscientious and conservative.

Answer collected from stackoverflow and other sources, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0