• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            woaidongmao

            文章均收錄自他人博客,但不喜標題前加-[轉貼],因其丑陋,見諒!~
            隨筆 - 1469, 文章 - 0, 評論 - 661, 引用 - 0
            數據加載中……

            HTTP/1.1 Cache-Control的理解

                 網頁的緩存是由HTTP消息頭中的“Cache-control”來控制的,常見的取值有privateno-cachemax-agemust-revalidate等,默認為private。其作用根據不同的重新瀏覽方式分為以下幾種情況:
            1) 打開新窗口
            如果指定cache-control的值為privateno-cachemust-revalidate,那么打開新窗口訪問時都會重新訪問服務器。而如果指定了max-age值,那么在此值內的時間里就不會重新訪問服務器,例如:
            Cache-control: max-age=5
            表示當訪問此網頁后的5秒內再次訪問不會去服務器
            2) 在地址欄回車
            如果值為privatemust-revalidate(和網上說的不一樣),則只有第一次訪問時會訪問服務器,以后就不再訪問。如果值為no-cache,那么每次都會訪問。如果值為max-age,則在過期之前不會重復訪問。
            3) 按后退按扭
            如果值為privatemust-revalidatemax-age,則不會重訪問,而如果為no-cache,則每次都重復訪問
            4) 按刷新按扭
            無論為何值,都會重復訪問
            clip_image001

            項目中使用過濾器來設置網頁的緩存

            clip_image002FilterConfig fc;
            clip_image002
            clip_image002   
            public void doFilter(ServletRequest req, ServletResponse res,
            clip_image003clip_image004            FilterChain chain)
            throws IOException, ServletException clip_image005{
            clip_image006        HttpServletResponse response = (HttpServletResponse) res;
            clip_image006       
            // set the provided HTTP response parameters
            clip_image007clip_image008
                    for (Enumeration e = fc.getInitParameterNames(); e.hasMoreElements();) clip_image005{
            clip_image006            String headerName = (String) e.nextElement();
            clip_image006            response.addHeader(headerName, fc.getInitParameter(headerName));
            clip_image009        }
            clip_image006       
            // pass the request/response on
            clip_image006
                    chain.doFilter(req, response);
            clip_image010    }


            配置文件的配置:

            clip_image002<filter>
            clip_image002       
            <filter-name>NoCache</filter-name>
            clip_image002       
            <filter-class>filter.CacheFilter</filter-class>
            clip_image002       
            <init-param>
            clip_image002           
            <param-name>Cache-Control</param-name>
            clip_image002           
            <param-value>no-cache, must-revalidate</param-value>
            clip_image002       
            </init-param>
            clip_image002   
            </filter>
            clip_image002   
            <filter>
            clip_image002       
            <filter-name>CacheForWeek</filter-name>
            clip_image002       
            <filter-class>filter.CacheFilter</filter-class>
            clip_image002       
            <init-param>
            clip_image002           
            <param-name>Cache-Control</param-name>
            clip_image002           
            <param-value>max-age=604800</param-value>
            clip_image002       
            </init-param>
            clip_image002   
            </filter>
            clip_image002
            clip_image002   
            <filter-mapping>
            clip_image002       
            <filter-name>CacheForWeek</filter-name>
            clip_image002       
            <url-pattern>*.js</url-pattern>
            clip_image002   
            </filter-mapping>
            clip_image002   
            <filter-mapping>
            clip_image002       
            <filter-name>CacheForWeek</filter-name>
            clip_image002       
            <url-pattern>*.css</url-pattern>
            clip_image002   
            </filter-mapping> 
            clip_image002   
            <filter-mapping>
            clip_image002       
            <filter-name>CacheForWeek</filter-name>
            clip_image002       
            <url-pattern>*.gif</url-pattern>
            clip_image002   
            </filter-mapping> 


            上述設置保存了1周的緩存。

            posted on 2009-09-10 11:48 肥仔 閱讀(1556) 評論(0)  編輯 收藏 引用 所屬分類: HTTP & URL

            AV无码久久久久不卡蜜桃| 国产2021久久精品| 国产真实乱对白精彩久久| 66精品综合久久久久久久| 亚洲天堂久久精品| 国产视频久久| 久久亚洲国产成人影院| 久久久一本精品99久久精品88| 亚洲欧美日韩中文久久 | 国产91久久精品一区二区| 国产69精品久久久久9999| 久久综合伊人77777| 色妞色综合久久夜夜| 久久精品国产99久久久香蕉| 久久久久久久女国产乱让韩| 91麻精品国产91久久久久| 四虎国产精品成人免费久久| 久久亚洲视频| 奇米综合四色77777久久| 久久99精品久久久久久不卡 | 一本久久a久久精品亚洲| 99精品久久精品一区二区| 亚洲欧美国产日韩综合久久| 国产精品久久亚洲不卡动漫| 久久夜色精品国产噜噜亚洲a| 国产V亚洲V天堂无码久久久| 亚洲综合久久久| 66精品综合久久久久久久| 久久综合给合久久狠狠狠97色69| 久久久久婷婷| 久久99精品国产麻豆婷婷| 久久精品国产69国产精品亚洲| 亚洲αv久久久噜噜噜噜噜| 中文无码久久精品| 99久久国产亚洲高清观看2024| 久久午夜无码鲁丝片秋霞| 久久久网中文字幕| 久久久久国产精品三级网| 伊人久久综在合线亚洲2019| 国产精品福利一区二区久久| 久久久久亚洲av无码专区导航|