Is there any good cache for PHP? for example, if I want to cache the index. php homepage and update it once every 10 minutes, how can I write the cache! Is there any good cache for PHP?
For example, if I want to cache the index. php homepage and update it once every 10 minutes, how can I write the cache!
I used to do. net, but now I want to switch to PHP, and many pages need to be cached. I don't know how to write php.
Please have a demo.
For example, if index.php is used, another user will update index.html every 10 minutes. of course, index.html is the cache of index. php,
In time, no index.html is generated,
Index. php is required to update data once every 5 minutes.
How to write !!!
Best generation !!
------ Solution --------------------
Use the smarty template. there is a cache in it, http://www.smarty.net/docsv2/en/. there are a few more features in the manual. click here.
------ Solution --------------------
Full English
------ Solution --------------------
Memcached
------ Solution --------------------
What do you do in. net?
It's just a dialect.
------ Solution --------------------
Reference:
Memcached
Memcached cache page? I have never done it. is it because I threw the whole page into a value?
------ Solution --------------------
In this scenario, memcached performs caching. Not to mention the amount of communication, you have to load php, read it from the memcached server, and then return it to the client each time a pure static page is generated, which is very inefficient.
The recommended example is to cache the file generated by index.html, and then run the script to update the file regularly.
------ Solution --------------------
To cache, you must first know why you want to cache and what you want to cache...
Every answer on the floor is feasible to some extent. The key is what you want to do...
------ Solution --------------------
To cache the entire page, you can directly create a static file. Ob_start (), ob_get_contents (), flush (), or ob_flush (). These four functions are sufficient.
When you request this page each time, determine whether the static file exists or the current time-its creation time is greater than or equal to 10 minutes. Then, use the above method to generate a static page. Otherwise, the static file will be read and returned to the browser.
------ Solution --------------------
Memcached or redis is suitable for caching data. it is the best method to cache the entire page.
------ Solution --------------------
Couch db
------ Solution --------------------
Thanks for your help. I tested a page cache and generated an html file. The key is not what I need,
For example, when I query data based on conditions, the cache time is set to 1 minute,
As a result, I select the query condition. The data has not changed.
I want to select the query time, data changes, colleagues, the same query conditions, updated once every minute,
For example, if I select a time zone, the default start time is the data of the last day,
When I select the day before yesterday's condition query, I want the verse of the day before yesterday,
If I re-query the data of the day before yesterday, but the data of the day before yesterday is not updated within one minute, the data will be updated only after one minute,
In one minute, when I select the acquired data, it is the acquired data, not the data of the day before yesterday.
That is, the query condition is changed, and cache is performed for 1 minute, 1 hour, and 1 day according to the condition of the day,
Other condition queries are not affected. of course, other conditions are one minute or one hour. 1-day cache
------ Solution --------------------
To put it bluntly, data is cached based on the condition query.
------ Solution --------------------
According to your #11 description, your ideas are problematic.
In this case, you need to cache the site at all times since your history. Because anyone can start querying at any time in the past.
It takes at least 6151680 cache items for a period of one minute.
This is obviously not desirable.
Because the available query expressions are limited, you can create several views based on the query expressions. This completes the query operation and the database background.
------ Solution --------------------
Yes! That's a headache !!!
So I want to put it in the memory, and then regularly clean up the memory.
------ Solution --------------------
Use the input/output buffer to cache files
------ Solution --------------------
Newbie, pass ~ I think it is better to use static page cache.
------ Solution --------------------
This is the same as the homepage cache of some website navigation websites. However, they may cache the homepage for a longer period of time on the client, such as one month or three months ......
The specific method is:
1. store the relevant elements referenced on the home page (images, CSS files, and JS files) in a dedicated directory, such as cache;
2. add rules to. htaccess:
# Cache home page objects
# RewriteCond % {HTTP_HOST} ^ www.162100.com [NC]
# RewriteCond % {REQUEST_URI} ^ $ [OR]
# RewriteCond % {REQUEST_URI} ^/$ [OR]
# RewriteCond % {REQUEST_URI} ^/index.html $ [NC]
# RewriteRule (index \. html) gzip. php? Cfile = $1 [L]
# RewriteRule ^ (cache \/. +) $ gzip. php? Cfile = $1 [L]
3) create a file gzip. php in the root directory (that is, a directory with index.html) with the code: