I have an idea about static website caching. I have never learned about caching or anything. I always feel a little bloated. I hope that some simple and clear statements can be used to implement what I want. I am still a beginner in PHP, so you can discuss it. I want to design it like this. there is a table in the database & nbsp; web_page & nbsp; simple Field ID & nbsp; web_Url & nbsp has an idea of static website cache. Let's discuss it.
I have never learned about caching or anything. I always feel a little bloated.
I hope that some simple and clear statements can be used to implement what I want.
I am still a beginner in PHP, so you can discuss it.
I want to design it like this. the web_page field in the database is simple.
ID Web_Url Web_Key Web_UpDate
Users can access a page of the website at will and obtain the URL to the database for judgment,
If the page does not exist, generate a KEY and time for the page and passing parameters to be written to the database.
Generate a file named Web_Key to/temp /.
If you access this page again next time, determine whether the time is greater than the set 30 minutes,
If the value is smaller than, the web_key file is called directly. if the value is greater than, the file is generated again and updated at the same time.
In this way, the entire site can be cached in/temp/, and the validity period is set to 30 minutes or longer, because if no one accesses the site, it will not be updated.
Let's talk about this idea? This is my entry-level idea. Let's talk about it... Haha ..
------ Solution ----------------------
The implementation you introduced can also be
An implementation method is introduced here: the md5 value of the page address url is used as the first two characters of the file name as the file name, and then determined by file_exists.
------ Solution ----------------------
Unfortunately, your thinking is exactly what the bloated Cache mechanism uses.
But people do not need:
Obtain the URL to the database and determine whether the URL does not exist. if the URL does not exist, generate a KEY and time for the page and pass parameters to the database.
Instead, replace the characters that cannot appear in the file name from the url to get the cached file name.
Check whether the file exists. if the file does not exist or the file modification time is earlier than the agreed time, the cache file will be re-generated.