e2openplugin-OpenWebif icon indicating copy to clipboard operation
e2openplugin-OpenWebif copied to clipboard

Include JS and CSS min with version

Open jbleyel opened this issue 3 years ago • 12 comments

Change all imports like this:

OLD: <script type="text/javascript" src="js/openwebif-1.2.20.min.js"></script> NEW: <script type="text/javascript" src="js/openwebif.min.js?v1.2.20"></script>

To force browser cache reload on changed.

jbleyel avatar Feb 27 '21 09:02 jbleyel

+1 - I don't think it breaks anything.

rdamas avatar Feb 27 '21 10:02 rdamas

It makes the development much easier too.

jbleyel avatar Feb 27 '21 10:02 jbleyel

I would prefer to see optimised http etag and cache headers as it shouldn't be necessary to modify .tmpl each time a js file is versioned. Alternatively, there are build tools which can replace paths in html with version/checksum numbers.

(I know Firefox has historically had a very aggressive caching strategy.)

wedebe avatar Feb 27 '21 14:02 wedebe

I use Chrome and i always need to reload the js files separately. We can use the hash of the file and modify the tmpl files automatically by build-js but only if changed.

jbleyel avatar Feb 27 '21 14:02 jbleyel

With an etag the browser still has to query the server (using HEAD) if the status of the file in cache is still valid. You have to die one dead here (as we say here).

rdamas avatar Feb 27 '21 18:02 rdamas

We can use something like this.

https://github.com/techjacker/node-version-assets

jbleyel avatar Feb 27 '21 18:02 jbleyel

I have checked node-version-assets. It works but it's BAD because we get always a new name for the css and js. This needs a huge cleanup on the box.

jbleyel avatar Feb 27 '21 19:02 jbleyel

Classic JS -> DONE

jbleyel avatar Feb 27 '21 21:02 jbleyel

May I suggest using an $assetCacheBuster variable in .tmpl files with a singular value set in the base controller or main.tmpl?

#set $assetCacheBuster = '1.3.2'

...

<script>openwebif.js?v=$assetCacheBuster</script>

wedebe avatar Mar 01 '21 10:03 wedebe

Yes, we can do this. But normally we do have that much changes. And we have different versions of the js files. I think autogenerated md5 hash of the file will be better.

Something like the node-version-assets. But without renaming the file itself.

jbleyel avatar Mar 01 '21 17:03 jbleyel

#1392 starts the journey towards automated versioning for modern (utilising webpack for js build).

There's more work to be done such as modifying the CI build to generate modern assets before tmpl -> py build compilation.

wedebe avatar Aug 21 '21 21:08 wedebe

You do not need to think about this. The templates will be compiled again after /CI/build.sh

jbleyel avatar Aug 21 '21 22:08 jbleyel

Will be fixed in 2.0

jbleyel avatar Sep 21 '22 06:09 jbleyel