I want to implement a two pass cache system:
The first pass generates a PHP file with all the usual things (like news) hardcoded. Then the database has a cache table that links them to pages (for example, "index.php page = 1 style = default"), the database also saves the uptodate field, which, if false, causes the first pass to restart the next time page is being viewed.
The second passage fills in small details, for example, how long has something (?) Been, and variable elements, such as "You are logged in as ...".
However, I am not sure of an effective implementation that supports both cached and non-cached (e.g. search) pages, without a lot of code and a few requests.
Currently, every time a page loads, a PHP script starts a page regeneration. For pages like search, this is good because most searches are different, but for other pages, such as index, it is almost the same for each hit, but generates a large number of requests and a rather long script.
The problem is that some parts of the page are changed for each user, for example, the “You are logged in as ...” section, so just saving the generated pages will still result in 10,000 almost identical pages.
The main problem is to reduce the load on the server, because I am on a shared hosting and currently can not afford to upgrade, but the site uses a significant part of the CPU + servers, which establishes a fair load on the MySQL server.
Thus, basically minimizing how much you need to do for each page request, rather than restoring things like news in the index, it always seems like a good start, compared to searching, which is a much less static page.
I really considered hard-coding news as plain HTML, but then this means that they support them in several places (since they can be used for searching, and comments on the page dedicated to this news item (for example, news.php), and so on. .d.).