Search code examples
intellij-ideajettyhtml5-appcache

Chrome's App Cache don't update files even it says: Application Cache Downloading event


I've configured App Cache manifest in my web app, chrome detects when it's content is changed, triggers "Application Cache Downloading event" but content is not updated.

What can it be?


Solution

  • As I can read here :

    THE APPLICATIONCACHE IS AN ADDITIONAL CACHE, NOT AT ALTERNATIVE ONE When the browser updates the ApplicationCache, it requests urls as it usually would. It obeys regular caching instructions: If an item’s header says “assume I’m good until 1st April 2022” the browser will assume that resource is indeed good until 1st April 2022, and won’t trouble the server for an update. This is a good thing, because you can use it to cut down the number of requests the browser needs to make when the manifest changes. This can catch people out while they’re experimenting if their servers don’t serve cache headers. Without specifics, the browser will take a guess at the caching. You could update whatever.html and the manifest, but the browser won’t update the file because it’ll “guess” that it doesn’t need updating. All files you serve should have cache headers and this is especially important for everything in your manifest and the manifest itself. If a file is very likely to update, it should be served with no-cache. If the file changes infrequently must-revalidate is a better bet. For example, must-revalidate is a good choice for the manifest file itself. Oh, while we’re on the subject…

    Now I think i have to enable no-cache headers to all files from my server and rely only in the appcache, but

    1. How I enable no-cache headers in my local intellij web server ?

    Answer: intellij canno't disable client cache from his built in server, but you can do it from chrome: Disabling Chrome cache for website development

    1. How I enable no-cache headers in my server with jetty-runner ?

    Answer: Acording to this, you should modify webdefault.xml

    <!--
    <init-param>
          <param-name>cacheControl</param-name>
          <param-value>no-cache,public</param-value>
    </init-param>
    -->
    

    But it's easier to place it to your web.xml file:

    <servlet>
      <servlet-name>default</servlet-name>
      <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
      <init-param>
        <param-name>cacheControl</param-name>
        <param-value>no-cache,public</param-value>
      </init-param>
    </servlet>