Example: implementing static caching of Dynamic Web pages

Source: Internet
Author: User

A line of code to implement the cache of temporary file saving, four lines of code to achieve cache judgment, three lines of code to implement temporary file invocation

Source Dynamic Web page

<title> Example: Implementing static caching of Dynamic Web pages </title>

(example file: _samples/file_page.html)

Read the cached static file information

<file act=info>web-inf/cache/page_test.html</file>

Determine if a static file exists

<if x= "@{file:exists}" else=0>    <call>page</call>    <callx=true>cache</call> </if>

exists on the call Cache , the call is not present page

   <call>page</call>    <call x=true>cache</call>

Callable Tag Cache , read cache file

<chtml onlycallid=cache><file act=read method=str name=page>web-inf/cache/page_test.html</file> </chtml>

Callable Tags Page

<chtml id=page file= "@{sys:curpath}file_page.html" save= "web-inf/cache/page_test.html" Onlycall/>

Introduce dynamic Web page file @{sys:curpath}file_page.htmland Save as web-inf/cache/page_test.html file

displaying cached content

@{file:page}

Full code

Effect


(example file: _samples/file_cache.html)

Experience it!

Download and description of light-open platform resources

Platform and Latest development Manuals free Download: http://download.csdn.net/detail/tx18/8464425

Development example: Light Open e-commerce website , free download: http://download.csdn.net/detail/tx18/8318585

The light-open platform will be upgraded to provide you with more powerful and easy features, please note the latest development manuals

Example: implementing static caching of Dynamic Web pages

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.