solutionweb

WordPress Common Errors and Solutions

A method of generating static cache file by wordpress without plug-in

A method of generating static cache file by wordpress without plug-in

Speaking of wordpress generating static cache? The first thing that comes to mind is the WP Super Cache plug-in. Indeed, most wordpress webmasters are using it.

But there will always be people who are obsessed with perfectionism, and there are also many people who don’t like to use plug-ins. Today, the method of generating static cache files by wordpress without plug-ins can get rid of the use of this powerful wordpress cache plug-in WP Super Cache for everyone!

First of all, let’s talk about the working principle of WP Super Cache. The Mod_rewrite acceleration mode of this plug-in has a very good acceleration effect, because this mode directly generates static html pages from the pages of the website, and then forwards the requests to static files by using Mod_rewrite, thus skipping the php parsing step and directly spitting out the pages to the browser, thus achieving the acceleration effect.

The tutorial introduced today is almost the same as the above working principle, and with the use of acceleration classes such as CDN, the effect will be very obvious, and the speed will be 100%!

Operation tutorial

PHP Code copies the content to the clipboard.

CACHE_LIFE){

unlink($file);

}

}

}

ob_start(‘auto_cache’); //callback function auto_cache

}

else{

The if (file _ exists ($ cache _ file)) {//file _ exists () function checks whether the file or directory exists.

unlink($cache_file); //Delete the cache file without the request of GET.

}

}

? >

There are comments in the code. Save the code as a cache.php file, and then put it in the root directory of the website. Remember, it is the root directory of the website, not the root directory of wordpress theme! Then create a cache folder for the root directory of the website and give 777 write permission.

And then put the code

The code is as follows:

require(‘cache.php’);

Index.php’s

Back to top