mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Restore caching busting functionality without using explict version number
Fixes #4503
This commit is contained in:
		| @@ -13,6 +13,7 @@ | ||||
|  * See the License for the specific language governing permissions and | ||||
|  * limitations under the License. | ||||
|  **/ | ||||
| const crypto = require('crypto') | ||||
| var express = require('express'); | ||||
| var fs = require("fs"); | ||||
| var path = require("path"); | ||||
| @@ -28,6 +29,8 @@ var editorClientDir = path.dirname(require.resolve("@node-red/editor-client")); | ||||
| var defaultNodeIcon = path.join(editorClientDir,"public","red","images","icons","arrow-in.svg"); | ||||
| var editorTemplatePath = path.join(editorClientDir,"templates","index.mst"); | ||||
| var editorTemplate; | ||||
| const version = require(path.join(editorClientDir,"package.json")).version | ||||
| const cacheBuster = crypto.createHash('md5').update(version).digest("hex").substring(0,12) | ||||
|  | ||||
| module.exports = { | ||||
|     init: function(_runtimeAPI) { | ||||
| @@ -99,6 +102,7 @@ module.exports = { | ||||
|         } | ||||
|         res.send(Mustache.render(editorTemplate,{ | ||||
|             sessionMessages, | ||||
|             cacheBuster, | ||||
|             ...await theme.context() | ||||
|         })); | ||||
|     }, | ||||
|   | ||||
| @@ -24,24 +24,24 @@ | ||||
| <title>{{ page.title }}</title> | ||||
| <link rel="icon" type="image/png" href="{{ page.favicon }}"> | ||||
| <link rel="mask-icon" href="{{ page.tabicon.icon }}" color="{{ page.tabicon.colour }}"> | ||||
| <link rel="stylesheet" href="vendor/jquery/css/base/jquery-ui.min.css?v={{ page.version }}"> | ||||
| <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css?v={{ page.version }}"> | ||||
| <link rel="stylesheet" href="red/style.min.css?v={{ page.version }}"> | ||||
| <link rel="stylesheet" href="vendor/jquery/css/base/jquery-ui.min.css?v={{ cacheBuster }}"> | ||||
| <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css?v={{ cacheBuster }}"> | ||||
| <link rel="stylesheet" href="red/style.min.css?v={{ cacheBuster }}"> | ||||
| {{#page.css}} | ||||
| <link rel="stylesheet" href="{{.}}"> | ||||
| {{/page.css}} | ||||
| {{#asset.vendorMonaco}} | ||||
| <link rel="stylesheet" href="vendor/monaco/style.css?v={{ page.version }}"> | ||||
| <link rel="stylesheet" href="vendor/monaco/style.css?v={{ cacheBuster }}"> | ||||
| {{/asset.vendorMonaco}} | ||||
| </head> | ||||
| <body spellcheck="false"> | ||||
| <div id="red-ui-editor"></div> | ||||
| <script src="vendor/vendor.js?v={{ page.version }}"></script> | ||||
| <script src="vendor/vendor.js?v={{ cacheBuster }}"></script> | ||||
| {{#asset.vendorMonaco}} | ||||
| <script src="{{ asset.vendorMonaco }}?v={{ page.version }}"></script> | ||||
| <script src="{{ asset.vendorMonaco }}?v={{ cacheBuster }}"></script> | ||||
| {{/asset.vendorMonaco}} | ||||
| <script src="{{ asset.red }}?v={{ page.version }}"></script> | ||||
| <script src="{{ asset.main }}?v={{ page.version }}"></script> | ||||
| <script src="{{ asset.red }}?v={{ cacheBuster }}"></script> | ||||
| <script src="{{ asset.main }}?v={{ cacheBuster }}"></script> | ||||
| {{# page.scripts }} | ||||
| <script src="{{.}}"></script> | ||||
| {{/ page.scripts }} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user