JIRA doesn't delete/update plugin's old web-resources

Rafal Pysz September 1, 2011

I've created plugin for my JIRA which is using servlets and web-resources with few .js files. Unfortunatelly, I have problems while installing new versions of my plugin with changes in javascript files.


Declaration (atlassian-plugin.xml):


<web-resource name="Admin Web Resources" key="jirasyncresources">
...
<resource type="download" name="admin.js" location="admin.js"/>
....
</web-resource>

Simple situation:

1. I'm preparing JAR file with my plugin.

2. Installing plugin on my JIRA instance.

3. Uninstalling plugin from my JIRA instance (also deleting every plugin's JARs from JIRA\plugins\installed-plugins).

4. Making changes in admin.js file.

5. Creating new JAR file (atlas-clean, atlas-package)

6. Installing my new JAR on the same JIRA instance.

Plugin works but it's still using old version of admin.js (without changes from point 5). Probably JIRA keeps somewhere all web-resources and doesn't update them while installing new version of plugin.

Where JIRA is keeping all web-resources? Is it possible do clean them?

(I'm using JIRA 4.4)

6 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 1, 2011

I am guessing it is your browser that caches the files. Clear the cache and try again. Sometimes you just need to reload the page (Ctrl+F5 on firefox for eg.).

Rafal Pysz September 1, 2011

You're right, it's browser cache problem. Any way to force refreshing those files (in code)? Reloading doesn't help.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 1, 2011

You can rename the files in webresource which will force the browser to reload. Maybe use a versioning of files there!

Rafal Pysz September 1, 2011

Renaming files doesn't help because JIRA joins all .js files into one big "jirasyncresources.js". I can change web-resource key but it doesn't look like good solution - it will force me to change all "$webResourceManager.requireResource" declarations in every .vm file which is using my resources.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 1, 2011

Sorry, I meant webresource key. And yes, it will surely force you to change all references. I think you will have to have multitple webresource definitions to ease the pain! Unfortunately I don't know of any other solution. Someone else might ;)

5 votes
discountrobot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2015

(This is written with confluence in mind, but i guess it applies to JIRA aswell).

Asking the userbase to actively clear their cache is moronic.

Since web-resources are cached by their key it is needed to change this every time a new plugin update is released..

Including web-resource by their context instead of the key, makes it possible to add a randomly generated value to the web-resource key (thus forcing a resource update).

The random value i chose is simply the maven build timestamp

&lt;properties&gt;
  &lt;timestamp&gt;${maven.build.timestamp}&lt;/timestamp&gt;
&lt;/properties&gt;
&lt;web-resource key="${project.artifactId}-resources${timestamp}"     name="${project.artifactId} resources"&gt;
        ...
        &lt;context&gt;something.something.something&lt;/context&gt;
    &lt;/web-resource&gt;
$webResourceManager.requireResourcesForContext("something.something.something")

 

I haven't been able to access images with requireResourcesForContext, and my solution has been to create a normal web-resource only containing images. 

Jeremy Frank June 16, 2015

This sounded like such a good idea. I tried it, and indeed the key gets a timestamp appended to it. But after uploading the new plugin to Jira, the old sequence number on the batch.js file remains the same, so the browser's cached copy remains active.

Jeremy Frank June 17, 2015

I take that back... Further testing shows the sequence number stays the same, but there's a hash code in the URL that changes, so the new resources are indeed loaded. Thank you for your solution! Updating the plugin version number works as well, but you have to be careful, as Jira seems to refuse to install an "older" version plugin unless you uninstall first (so you can't add a timestamp during development then drop it for publishing unless you are careful to also increment your version number).

discountrobot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2015

Yea, common pitfalls was to ensure that the testing environment was not in dev mode. and not to test with atlas-cli, as that keeps building with the same timestamp

discountrobot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2015

Your approach to updating the plugin version seems more feasible to me. Thanks.

Jeremy Frank June 17, 2015

To update the plugin version automatically, change pom.xml by updating <project><version> to include .${maven.build.timestamp}.

discountrobot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2015

note that the default timestamp does not contain seconds, this can be fixed within <maven.build.timestamp.format></maven.build.timestamp.format>

1 vote
Dipesh Chouksey August 9, 2017

To fix this caching for new version of plugin. Whenever you changed the version in pom.xml then new web resource will be download at the client side.

Step 1:  Add the version in plugin.xml file.

<web-resource key="transaction-${project.version}" name="transaction-resources">

<context>transaction-resources</context>
</web-resource>

 

Step 2:  Call the web resource context in your tmplate(.vm file). 

<head>
$webResourceManager.requireResourcesForContext("transaction-resources")
</head>

Now if you release new version of your plugin then web resource key will be changed and new web resource will be download in client side. 

1 vote
MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 1, 2011

Is there anything that Wikipedia does not provide?

http://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache#Google_Chrome

0 votes
Herberts Markūns January 16, 2015

As rafal.pysz said, a good way to force to load updated resources without having user to clear the cache for the page, is to change the web resource name (add a version number or something), in atlassian-plugin.xml. 

Such as:
"<web-resource key="my-web-resources-v001".."

 

0 votes
MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 1, 2011

It's client (browser) side, so I usually check that the browser cache has been cleared and then it refreshes nicely. I would like a "don't cache files from this site" choice in Chrome or Firefox. Using an incognito window in Chrome might work?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events