Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instant cache refreshing on ZMI-JS changes #345

Merged
merged 4 commits into from
Dec 16, 2024
Merged

Conversation

drfho
Copy link
Contributor

@drfho drfho commented Dec 14, 2024

Ref: https://github.com/idasm-unibe-ch/unibe-cms/issues/744

ZMI-JS-code changes may be unseen after deployment due to proxy caching. A hash value of the minified ZMI-JS code (created on Zope start) will refresh the proxy caching of the minfied file /++resource++zms_/zms-all.min.js.

The code proposal determines the hash value from the freshly created zms-all.min.js-file and writes it as

  1. file zms-all.min.js.hash into the file system and
  2. default-value of a new config-param js_min.hash

Thus it is easy to

  1. check whether the current hash value is actually used in the frontend
  2. apply it to the template-code with common API-function zmscontext.getConfProperty('js_min.hash')

Any code status will result in a specific hash-value ...

hash1

... and create a new URL for zms-all.min.js:

hash0

@drfho drfho requested review from cmeier76 and zmsdev December 14, 2024 11:01
Copy link
Contributor

@zmsdev zmsdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comment.

# a. write it into separate file and
# b. create a configuration parameter
min_fileobj = open(fileobj.name, 'r')
min_hash = standard.encrypt_password(min_fileobj.read(),hex=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use the python builtin hash()-function and hexlify the result?
Password encryption maybe misleading and change its behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@zmsdev zmsdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@drfho drfho merged commit 2b83b69 into main Dec 16, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants