thinkphp Static Cache usage Analysis

Source: Internet
Author: User
thinkphp static cache usage, thinkphp static cache configuration method and operation skill, thinkphp built-in static cache function, can directly call the generated HTML cache file, need to refer to the friend.

thinkphp Static Cache usage

Thinkphp built-in static cache function, 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, Instead, the generated HTML cache file is called directly.

To use a static cache, you need to add the static cache rule file htmls.php under the project configuration directory __app__/conf, and you need to open the static cache in the configuration file:

' Html_cache_on ' =>true

To set a static page save path that has been generated:

' Html_path ' = ' __app__/html '

To set the default cache validity time:

' Html_cache_time ' = ' 60 '

Rules for reading static pages

' 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.

Cache rule settings, which operations are statically cached, the name of the cache HTML, and the cache time, return array ("Action name" =>array ("HTML static file name to generate", "set cache validity period", "Generate file name rules")

The "Operation name" above is the operation that needs to be cached, and the operation name is in three forms. 1. If you write only the name of the operation, that is, the operation name of all the modules under the project is cached. 2, module name: The operation name, which means that only the module below the operation 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 the. 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 validity, in seconds, set to 1 for permanent cache, the rule to generate file names is to rename the generated static file through a function, such as MD5.

  • 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.