Way from the WordPress-Cache plugin to WEB static HTML generated strategy

xiaoxiao2021-04-01  225

1 For the first time, check if the file exists, if there is no cache, remove the file from the database to the cache, after access, take directly from the cache. Each static page requires an auxiliary META file, such as WP-Cache-12345.meta

Why do you need a separate META? Because it is not enough to return a static HTML, there are many information, such as the time of this page, Content-Type and other information. This information cannot be stored in HTML, so you need to assist .meta file

The content in the meta file is: $ meta_object-> uri = $ _server ['Request_uri']; $ meta_object-> post = wp_cache_post_id (); $ meta_object-> Dynamic = true; $ meta_object-> headers = array ();

Array_push ($ meta_object-> Headers, "Last-Modified: $ Value"); Array_Push ($ meta_object-> headers, "content-type: $ value");

2 If an article is modified, remove the cache of this article, if a blog is changed, remove the entire Blog's cache. Follow 1 logic.

WP-cache-phase1 checks if a page exists, if there is a direct cache. Otherwise, enter the WP-CACHE-PHASE2, access the dynamic page, generate a cache file to use OB_Start ('wp_cache_ob_callback'; register_shutdown_function ('wp_cache_ob_end'); wp_cache_ob_callback wp_cache_ob_end

There is a role wp-cache-phase2 is incident response page, for example publish_post edit_post delete_post publish_phone trackback_post pingback_post comment_post edit_comment wp_set_comment_status delete_comment switch_theme, no matter what the event, in essence, is to empty the cache inside page

Use this plug-in to need a modified place 1 cache: Need to have an incrude file, according to URL, unified judgment all access 2 event response:

Due to the hard disk file system, the number of files in the same directory exceeds 3,000, and the access will be relatively slow, so the structure of the cache file is on the hard disk: It is necessary to increase the directory, which can improve the index speed, and the deletion is more convenient to follow the user, classify , Date or other attribute to establish a directory

转载请注明原文地址:https://www.9cbs.com/read-131305.html

New Post(0)