OSCache文档原文:(20081023日 在线文档会有定期更新,但本质改变不会太大)
http://www.opensymphony.com/oscache/wiki/CacheFilter%20Tutorial.html
中文解释:
OSCache利用一个servlet过滤器很明显的缓存您网站的一个整体页面,甚至于二进制文件。在我们生成动态(信息)时缓存二进制文件是非常有用的,比如:PDF文件或者图片。根据网页头部的最后修改时间处理上面的问题和服务器加载,在提高服务器响应时间上处理的是非常优秀的。
怎么样去配置OSCache去缓存整体servlet响应是在configuration page of the CacheFileter中描述的。这个简短的指南将要展示怎样使您的网页响应更加的迅速,和保存加载(信息)在你的服务器上。使用CacheFilter,用户将会体验到一个更快的(缓存)的网页(内容)和在更多的情况下更多的访问量。
Improvements较大的改进是在2.2和2.3发行版本中的CacheFilter:Default initialization of the last modified header which reduces transaction overhead and server load CRON expressions to expire content at specific dates and/or times Preserving more http headers, e.g. the expires header Special handling for fragments of a page Custom cache key generation by subclassing CacheFilter or by implementing a special interface Custom cache groups generation by subclassing CacheFilter or by implementing a special interface Support of GZip filters in the filter chain Avoids session creation for application scope pages Reduced memory consumption Multiple matching cache filters won't dead-lock the response anymore The cache won't be serve the same response twice before the client begins to cache it anymore
Cacheable Content注意:过滤器仅仅保存状态为200的内容(HttpServletResponse.SC_OK).
Configuring the filter
Example 1
要配置过滤器,首先要加一些东西(代码)想下面给你的web.xml文档(显然你将要设置URL映射去匹配那些仅仅你希望缓存的内容
;这个例子将缓存所有的JSP页面10分钟在session域内。
"<"filter-name">"CacheFilter"<"/FILTER-NAME">""<"filter-class">"com.opensymphony.oscache.web.filter.CacheFilter"<"/FILTER-CLASS">""<"init-param">"time 600 scope session
CacheFilter *.jsp
默认的持续时间是一个小时并且默认的缓存作用域是application。你可以改变这些设置用initialization parameters(笔者注:这是个文档链接).
Example 2基于当前时间的针对最后修改时间标记的初始化减少了处理(资源)耗费和服务器加载此外,如果expires参数设置为了time,被鉴定为未更新内容之后,服务器将要发送日期和时间。那时,直到已经缓存的内容被鉴定为未更新的,通常的浏览器不会向服务器请求任何东西。在这个例子中将要缓存内容一个小时,根据默认的并且终止日期和时间将要被计算(基于简历时间和时间参数)(默认是一个小时)Using the filterExample 1:ICacheKeyProvider这是一个简单的例子(指导我们)如何去用CacheFilter类ICacheKeyProvider参数。这个缓存参数被构建在用http请求URI和伴随pageid\pagination两个参数时。你可以使用session描述来完成缓存参数设置,如果请求参数不可用或者(例如.)安全设置不得不加入缓存参数。Example 2:Flush这个刷新例子占线了怎么去刷新一个在group names上CacheFilter(缓存过滤器)在application作用域。在这个例子用户得到缓存独享,HTTPservlet请求是必须的,如果缓存过滤器运行在session作用域,你不得不向一下这样得到缓存:
No comments:
Post a Comment