I have a custom field plugin that requires a .js file that defines some logic for the field, and I was wondering if there was a way to force my browser to grab the latest version without doing a hard refresh?
The reason I'm asking is because while hard-refreshing isn't a difficult thing for me to do while debugging, I would like to remove the need for my users to do this each time I cut a new release with new logic/features in the JS file.
A naive solution I've been considering is to create a cookie that expires every X days, and if the cookie doesn't exist then force a hard refresh via
but the problem here is that if I push a new release before the most recent cookie expires then my users won't get new features for a few days (or unless they manually hard refresh). It's of course possible to reduce the validity period to be a shorter amount of time, but then I wouldn't want users' pages to be hard-refreshing too often.
I know some web frameworks will automatically append some random string to the end of the JS file each time it builds so that the browser doesn't cache it. Is this something I can configure for a Jira plugin as well?
Edit: Another solution I've tried is:
1. Inject the current project version into the velocity parameters via the getVelocityParameters() method in the Java plugin code.
2. Set the value of a hidden textarea in the velocity template to be that version string
3. Check for a cookie with that version string, and then reload/create the cookie as necessary.
The problem with this approach is that since I'm injecting a version string into my plugin's velocity template, it can only read from that hidden textarea when my field is visible. The JS is loaded and executed on pages where my field may not be rendered yet (ex. a dashboard page), which means in those situations the cookie value effectively becomes "undefined", causing weird reload loops.
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot