Answer the question
In order to leave comments, you need to log in
How to make dynamic loading of static content on the page?
Hello!
I am almost finishing the transfer of the existing site from my "bike" to Symfony 4. And the site has blocks that are loaded by Ajax. And if these blocks were somehow generated or stored in the database, then they definitely need to be loaded by referring to some kind of controller that would return them. But most of them, 3 out of 4, are static and do not change. It turns out that for the sake of loading these static blocks, 3-4 processes will be launched each time with the launch of Symphony on the server.
I understand that the question has little to do with Symphony itself, rather a general one, relating to any CMS or framework. But I use Symphony, and it seems to be "heavier" than other brothers in terms of resource intensity.
Are there any features or tricks of working with Symphony in such situations? And in general, not only with Symphony, but with any other engines... Share your experience, please!
Thank you!
UPDATE: I forgot to add that I can't immediately insert this static content into the page, because it is repeated from page to page. And in order to improve search engine optimization, these pieces have to be inserted with Ajax after the page is loaded into the browser.
Answer the question
In order to leave comments, you need to log in
If the content is static, you can simply paste its HTML into the template. Otherwise, it's better to use HMVC: How to Embed Controllers in a Template
In the demo application, there are two examples illustrating the insertion of blocks with content: https://github.com/symfony/demo/blob/bbe5180a8c3b6... and https:// github.com/symfony/demo/blob/bbe5180a8c3b6...
The last example also uses ESI to cache the block.
Also, if the block is static, then you can not create a separate controller for it, but use the TemplateController: How to Render a Template without a custom Controller
But I use Symphony, and it seems to be "heavier" in terms of resource consumption than the other brothers
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question