Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 503150

Summary: Version resource.js file to prevent caching issues
Product: [RT] RAP Reporter: Chris Fairhall <chris>
Component: WorkbenchAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: ivan
Version: 3.1   
Target Milestone: 3.2 M7   
Hardware: PC   
OS: Windows NT   
See Also: https://git.eclipse.org/r/#/c/94742/
Whiteboard:

Description Chris Fairhall CLA 2016-10-03 16:18:18 EDT
As mentioned in https://bugs.eclipse.org/bugs/show_bug.cgi?id=439008 The file /rwt-resources/resources.js that is generated from extension point contributions is not versioned.

I suggest the file name be generated from a hash of the contents

The following is just one way this could be done 

org.eclipse.rap.ui.internal.servlet.ResourceRegisterer
import java.util.zip.CRC32;
....
private void registerConcatenatedScript() {
	final CRC32 crc32 = new CRC32();
	final byte[] script = concatenatedScript.getContent();
	crc32.update(script);
	final long crc = crc32.getValue();
	application.addResource("/resources-" + crc + ".js", new ResourceLoader() {
		public InputStream getResourceAsStream(String resourceName) {
			return new ByteArrayInputStream(script);
		}
	});
	applicationContext.getStartupPage().addJsLibrary("rwt-resources/resources-" + crc + ".js");
}

Alternately and perhaps a more flexible option would be to allow the 'rwt-resources' directory to be renamed or moved. Eg: from /rwt-resources to /rwt-resources-xyz or /xyz/rwt-resources
Comment 1 Chris Fairhall CLA 2017-04-12 17:23:21 EDT
I see the path for this file has been moved to "rwt-resources/" + SWT.getVersion() + "/resources.js"

However, the reason I suggested a hash of the content is because it's content is determined by the extension point "org.eclipse.rap.ui.resources", not the version of RAP deployed.

Also, when deploying milestone, RC or patched builds, SWT.getVersion does not change as it doesn't include the qualifier.
Comment 2 Ivan Furnadjiev CLA 2017-04-13 02:54:05 EDT
Chris... This change is consistent with the fix for bug 439008. I don't think that the content of this file is changed so frequently. Doesn't it?
Comment 3 Ivan Furnadjiev CLA 2017-04-13 03:24:34 EDT
... more over I want to expose these JS resources in a predicted path. Changing the path dynamically could lead to some problems with URL rewriting, proxies, load balancers, firewalls in a real deployment scenario.