Answer the question
In order to leave comments, you need to log in
How to cache a selection from the database and individual page elements?
Hello! The other day I wondered how best to organize caching. The matter is that I have some elements which are deduced once, and are which are deduced depending on request. For example, I get the main menu from the database and there is no need to change it until the end of the session, but every time the page is updated or the link is clicked, the database is accessed. I think that this will create a load on the server. Some pages also contain information that does not need to be updated frequently, for example, the product selection page in an online store, where I get almost all the content using an ajax request and there is a static menu that is large enough and there is no need to update it every time. I read somewhere about session caching and decided to give it a try. I pushed the catalog menu array and the menu array on the product page into the session and now I retrieve data from the database only when the page is first opened, then they are all taken from the session. But it seems to me that this is not correct and can create a greater load than a selection from the database. Please advise how best to organize such caching? There are certainly more effective methods designed for this. Thanks in advance!
Answer the question
In order to leave comments, you need to log in
I also found one article here: https://htmlweb.ru/php/php_cache.php
Which method is better to use? This one or the one described in the article?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question