thinkphp Static cache usage analysis, thinkphp static cache _php Tutorial

Source: Internet
Author: User

thinkphp Static cache usage analysis, thinkphp static cache


In this paper, the static cache usage of thinkphp is analyzed in detail. Share to everyone for your reference. The specific analysis is as follows:

Thinkphp has a built-in static cache function, saying that static caching may not be very good for my rookie. In fact, the static cache is the thinkphp of an operation to display the page generated an HTML file saved in the path of the setting, when the user again access, if the cache does not expire, then this operation will no longer execute the PHP program below it, but directly invoke the generated HTML cache file. To use a static cache, you need to add the static cache rule file htmls.php under the project configuration directory __app__/conf, and also to open the static cache in the configuration file: Copy the Code Code as follows: ' html_cache_on ' =>true

To set a static page save path that has already been generated: copy The code as follows: ' Html_path ' = ' __app__/html ' Sets the default cache validity time: copy code code as follows: ' Html_cache_time ' = > ' 60 ' Rules for reading static pages copy code as follows: ' Html_read_type ' =>0 ' Html_read_type is set to 0, that is, when accessing this cached operation, the operation reads the static cache page display. The URL path is the path to the operation. If set to 1, when the operation is accessed, it redirects to the static page. The URL is the cache file path.

The next step is to cache the rules, that is, to set what we want to statically cache, the name of the cache HTML, and the cache time, the copy code is as follows: Return Array ("Operation name" =>array (" To generate the HTML static file name "," Set cache validity period "," Generate file name rules ") above the" Operation name "is required to cache the operation, the operation name is divided into three different forms.

1. If you write only the name of the operation, it is the operation name of all the modules under the project cache.

2. Module Name: The operation name, which means that only the operation under the module is cached.

3. ' * ' indicates that all operations are cached. Generate the name of the static file, you can have the current module name {: module}, the current operation name {: Action},_get _request _server _session _cookie value ($_xxx) to set . where the $_get[' xxx ' parameter can be represented directly with {XXX}. If the file name contains "/" then the system will create a new directory in the Save directory, such as {: Module}/{:action}, the system will create a directory named after the current module name in the __app__/html directory, and then generate an HTML file named after the current operation name. Cache expiration, in seconds, set to 1 for permanent caching, and the rule for generating file names is to rename the generated static file through a function, such as MD5.

It is hoped that this article will be helpful to everyone's thinkphp framework design.

http://www.bkjia.com/PHPjc/919624.html www.bkjia.com true http://www.bkjia.com/PHPjc/919624.html techarticle thinkphp Static cache usage analysis, thinkphp static cache This paper analyzes the static cache usage of thinkphp in detail. Share to everyone for your reference. The specific analysis is as follows: Thin ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.