how to clear cache in gwt?

前端 未结 2 584
情书的邮戳
情书的邮戳 2020-11-30 06:04

How can I clear the cache in gwt?

or is there any way that prevent browser to keep the cache in gwt?

相关标签:
2条回答
  • 2020-11-30 06:44

    The best way to do it when you have an Apache2 server in the middle is configuring your Virtual Host in order to download css nocache files always. Here you have an example: http://pgt.de/2011/01/27/apache-configuration-for-gwt-applications/comment-page-1/#comment-23996.

    Put this on the Virtual Server file:

      <IfModule mod_expires.c>
         ExpiresActive On
      </IfModule>
    
      <IfModule mod_headers.c>
         <ProxyMatch (.*)nocache\.js$>
            Header Set Cache-Control "max-age=0, no-store"
         </ProxyMatch>
         <ProxyMatch (.*)\.cache\.(.*)>
            Header Set Cache-Control "max-age=31536000, public, must-revalidate"
         </ProxyMatch>
         <ProxyMatch (.*)\.cache\.js$>
            Header Set Cache-Control "max-age=31536000, private"
         </ProxyMatch>
      </IfModule>
    
     <Proxy *>
         <IfModule mod_expires.c>
            ExpiresByType application/json   "now"
            ExpiresByType text/css            "now"
            ExpiresByType text/html          "now"
         </IfModule>
         <ifModule mod_headers.c>
             Header unset ETag
             Header unset Last-Modified
         </ifModule>
         FileETag None
      </Proxy>
    

    Cheers

    0 讨论(0)
  • 2020-11-30 06:54

    When you deploy a GWT-application it's important to avoid proxies and browsers to cache the .nocache.js-files generated by GWT. One solution is to implement a servlet filter that adds the necessary HTTP-headers that control the caching behaviour.

    Here's such a filter: http://seewah.blogspot.com/2009/02/gwt-tips-2-nocachejs-getting-cached-in.html

    The headers in that example are:

    Date: Wed, 24 Nov 2010 20:32:43 GMT
    Expires: Wed, 01 Nov 2000 00:00:00 GMT
    Pragma: no-cache
    Cache-Control: no-cache, no-store, must-revalidate
    

    Date should be set to the time of the request.

    Expires is best set to sometime in the past, this forces everyone to consider the content already stale.

    Pragma is a tag that has been superseded by Cache-Control, but it doesn't hurt to have it.

    Cache-Control no-cache means a browser or proxy must revalidate a cached copy before releasing it to the client. no-store means no one is ever keeping a cached copy (which makes no-cache redundant). must-revalidate says the browser/proxy must obey freshness information and revalidate, also redundant with no-store.

    0 讨论(0)
提交回复
热议问题