[Seaside] Force Reload of Javascript

jtuchel at objektfabrik.de jtuchel at objektfabrik.de
Mon Sep 11 12:02:48 UTC 2017


Johan,

thanks for the tip on adding a parameter to avoid caching. We'll try that.

On the freshly rendered javascript: I might have found a clue as to what 
is happening there. If a cached javascript file has a syntax error, the 
embedded Javascript seems to be affected as well. So this is probably 
just the collateral damage of js errors in static files....


Joachim


Am 11.09.17 um 09:45 schrieb Johan Brichau:
> 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
> 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, jtuchel at objektfabrik.de 
>> <mailto:jtuchel at objektfabrik.de> 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 Tuchelmailto:jtuchel at objektfabrik.de
>> Fliederweg 1http://www.objektfabrik.de
>> D-71640 Ludwigsburghttp://joachimtuchel.wordpress.com
>> Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1
>>
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org 
>> <mailto:seaside at lists.squeakfoundation.org>
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


-- 
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:jtuchel at objektfabrik.de
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20170911/829aea51/attachment.html>


More information about the seaside mailing list