Oscache buffer technology used in JSP pages

Source: Internet
Author: User
1Http://www.opensymphony.com/oscache/
2. Add the downloaded jar to your build path.. We recommend that you directly put it under the tomcat/shared/lib directory.
3. Add configuration in Web. xml

        <taglib>
                <taglib-uri>oscache</taglib-uri>
                <taglib-location>/WEB-INF/classes/oscache.tld</taglib-location>
        </taglib>

4. Add the following tags to your JSP page:

<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache"%>

5. Use the following labels in the buffer area:

<Cache: cache key = "mypagecachekey" groups = "mydefaultgroup" Scope = "application" time = "1800">
... This is the content you want to buffer.
</Cache: cache>

6. Refresh the buffer

<cache:flush scope="application" group="myDefaultGroup" />

Parameter description
Key-[The default value is the request URI + query string]-
The cache key, any string. this shoshould be unique for the given scope since duplicate keys will map to the same cache entry. the default value uses an escaped version of The URI and query string of the current page.
It is possible to specify multiple cache tags in the same page without specifying keys-in this situation an index is appended to the key of subsequent tags. however this usage is discouraged since if the flow of the page is inconsistent, or cache tags are nested, The indicies will potentially change each time the page is executed, resulting in seemingly jumbled cache entries.
The buffered key, which can be any string. It is unique within a range, because the same key represents the same buffer entry. By default, the request URI and the request string are used (the Part following the question mark)

Scope-[Application]-the scope of this cache (valid values are "application" and "session ").
Range: Application and session. The default value is application.

Time-[1, 3600] The amount of time to cache this content for (in seconds ). (default is 3600 seconds, one hour ). supplying a negative value for this attribute means that the content never expires.
The buffer time (in seconds ). The default value is 1 hour, 3600 seconds. If the value is-1, the content will never expire.

Duration-[]-The duration of this cache (this attribute is an alternative to time). duration can be specified using simple date format or ISO-8601 date format.
Another method is to set the buffer time. You can use either simple date format or ISO-8601 Date Format

Cron-[]-A cron expression that determines when this cached content will expire. this allows content to be expired at participating dates and/or times, rather than once a cache entry reaches a certain age. see cron expressions to read more about this attribute.
Set timed refresh. Refresh can be performed at the specified time and period.

Refresh-[False]-A boolean. if true, the cache will be refreshed regardless of whether it is considered stale or not. this enables you to decide at runtime whether or not to rebuild the content.
Force refresh buffer

Mode-[]-Setting this to "silent" will prevent the body of the tag from being written to the output stream. this may be useful if you want to preload the cache with content without actually displaying that content to the user.
Setting it to [Silent] allows you to read the content in advance, but does not output it.

Groups-[]-A comma-delimited list of group names can be provided. this allows cache entries to be grouped according to your needs. grouping is useful when you have cached content that depends on other parts of your application or data-When that dependency changes, flushing the relevant group will cause all cache entries in that group to be expired.
Set Group. You can control the buffer data of the same group, such as refreshing

Language-[]-The ISO-639 language code to distinguish different content cached under an otherwise identical key. this is useful on a multilingual site where the same JSP code is used to render content in different versions depending on the current user's preferences.
Language, I have never used it, and I have not found any problems. The default is the language of the current page.

Refreshpolicyclass-[]-A fully-qualified classname that extends com. opensymphony. Oscache. Web. webentryrefreshpolicy. This allows you to programmatically determine whether cached content shocould be exipired.
Custom refresh policy class. Control when to refresh data

Refreshpolicyparam-[]-Any arbitrary parameters that you need to pass through to the refreshpolicyclass. Specifying this attribute without specifying a refreshpolicyclass will have no effect.
Parameters passed to the refresh policy class

Original address: http://www.java2000.net/viewthread.jsp? Tid = 2944

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.