vaadin / touchkit

TouchKit is a library of mobile components for Vaadin Framework
https://vaadin.com/touchkit
Other
11 stars 25 forks source link

CacheManifestLinker should use version numbers for cached resources #413

Open vaadin-bot opened 8 years ago

vaadin-bot commented 8 years ago

Originally by jarno.rantala


Since Vaadin 7.4.0 [https://vaadin.com/download/release/7.4/7.4.0/release-notes.html] the bootstrap javascript and themes are loaded with the version number:

Anyway, the current manifest file does not have a parameter. That would mean that the required resource is not cached at all so it always tries to fetch it from the server.

Current manifest:

CACHE MANIFEST
# Build timeMon Nov 30 10:03:10 EET 2015

CACHE:
../../../VAADIN/themes/base/fonts/fontawesome-webfont.woff
../../../VAADIN/themes/touchkit/styles.css
../../../VAADIN/vaadinBootstrap.js
...

There should be version numbers added to make the required resources cached

CACHE MANIFEST
# Build timeMon Nov 30 10:03:10 EET 2015

CACHE:
../../../VAADIN/themes/base/fonts/fontawesome-webfont.woff
../../../VAADIN/themes/touchkit/styles.css?v=7.6.0.beta1
../../../VAADIN/vaadinBootstrap.js?v=7.6.0.beta1
...

Imported from https://dev.vaadin.com/ issue #19321

vaadin-bot commented 8 years ago

Originally by @tepi


Workaround:

  1. Create a custom linker, e.g.
@LinkerOrder(LinkerOrder.Order.POST)
@Shardable
public class CustomLinker extends CacheManifestLinker {
    public CustomLinker() {
        addCachedResource("../../../VAADIN/vaadinBootstrap.js?v="
                + Version.getFullVersion() + " #.js");
        addCachedResource("../../../VAADIN/themes/yourtheme/styles.css?v="
                + Version.getFullVersion() + " #.css");
    }
}
  1. Note the comments at the end of the filenames, this is due to CacheManifestLinker's file extension filtering which I could not override.
  2. Add this to your .gwt.xml file, AFTER touchkit inherit to override the linker:
    <define-linker name="touchkitcachemanifest"
        class="com.your.project.widgetset.CustomLinker" />
    <add-linker name="touchkitcachemanifest" />

Confirmed to work on Android Chrome and iOS. Did not test on WP yet.