Re: Force Reload of Javascript
Johan Brichau <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <[email protected]> |
Hi Joachim, I recognize the problem when dealing with loading javascript resources, but not for Seaside-rendered javascript. I find the latter a bit strange since that gets injected in a load script or a script tag, and that cannot be cached unless your entire page is cached. So, when referencing javascript sources external to the Seaside image, this is what we do to ensure a browser does not use a cached version: https://stackoverflow.com/questions/9692665/cache-busting-via-params <https://stackoverflow.com/questions/9692665/cache-busting-via-params> In summary: - add a query parameter to the url of the javascript resource (i.e. behind the ‘?’ character) - use some version string in the code base as value in that query parameter such that it is different from the value in the current previous production version (using a version number is most intuitive). Here is the implementation for that in Seaside: updateRoot: aRoot … aRoot javascript resourceUrl: '/js-libs/jquery.dataTables.min.js' version: resourceVersion. … with the implementation of resourceUrl:version: is: WAContentElement>>resourceUrl: aString version: versionString "Concatenates a version string to the resource url. The version string is put in the GET request's variables list and ignored by the webserver. Changing the version string can trigger a browser cache refresh when needed." self url: ((canvas absoluteUrlForResource: aString) addField: versionString) Now, I am puzzled by the resources that are cached for generated javascript… can you share some more code on how that is included in your webpage? cheers, Johan > On 11 Sep 2017, at 08:41, [email protected] wrote: > > Hi there, > > > this may seem like a stupid question, but it seems I am struggling with the Browsers' cache handling of Javascript Code. > > Let me start by describing what happens: I change some javascript code in my Seaside app, deploy it onto the server and restart the image. > > For many (but not all) users, the changes don't get downloaded for days. They need to go to a page, press the Browser's reload button and from then on they are fine. This is both good to know and bad at the same time for several reasons: > > some users never call and are frustrated > the number of support cases causes high cost > The effect shows up both for Javascript that gets served from the file system (using rewrite rules) and for code served directly from Seaside in the render* methods. > For the file system stuff, we have to work on the caching settings on Apache. But I am really helpless in case of "freshly rendered" JavaScript code. How could that even be cached by a Browser??? > > Any hints are welcome > > > Joachim > > > > -- > ----------------------------------------------------------------------- > Objektfabrik Joachim Tuchel mailto:[email protected] <mailto:[email protected]> > Fliederweg 1 http://www.objektfabrik.de <http://www.objektfabrik.de/> > D-71640 Ludwigsburg http://joachimtuchel.wordpress.com <http://joachimtuchel.wordpress.com/> > Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1 > > _______________________________________________ > seaside mailing list > [email protected] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [email protected] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside