qooxdoo-compiler
qooxdoo-compiler copied to clipboard
FOR DISCUSSION ONLY: rework caching
load scripts using a fixed cache value defined as the compile time to solve caching issues. This PR only works with the following script added to index.html:
Hi, can you describe in more detail what problem this PR is trying to solve? Maybe there is a different way that does not require to add additional code.
Hi, this PR is for discussion only, I am facing issues with the caching mecanism on a server. Currently, there seems to have 2 ways of loading scripts with qooxdoo:
- loading scripts without dealing with cache
- loading scripts with cache busting i.e. adding ?nocache=Math.random()
but there is a third possible way : adding ?nocache=FIXEDVALUE where FIXEDVALUE would be defined at compile time. With this approach, each new compilation would skip caching on the browser side, but once the script is loaded, a browser refresh would use the cached file as FIXEDVALUE did not change.
The patch is really dirty, I just wrote it to solve my problem quickly, and it would need more work if this approach was to be included in qooxdoo...
I forgot to add that the script loading part in index.html would become:
${preBootJs}
<script type="text/javascript" src="${appPath}boot.js?nocache=${compileTime}"></script>
How about another solution - the scripts output into the boot.js file should have a timestamp which is the date that the file was last modified. This would only happen if addNoCacheParam
is true, and would limit the cache-busting to the exact minimum required.
If you wanted to code it that would be really helpful!
I've noticed that the addNoCacheParam has not been implemented in the compiler, so there are a few steps:
- Add a command line switch (in Compile.js) and entry in
compile.js
(schema) and then update the global config to suit. - Configure the target in Compile.js
- Add a property
addNoCacheParam
to Target.js - The list of URIs is output here https://github.com/qooxdoo/qooxdoo-compiler/blob/master/source/class/qx/tool/compiler/targets/meta/Package.js#L245-L248 - change that so that each URI has the file's last modified date/time
Thank you for all the pointers, I will do that!