Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I solved this problem recently by using RequireJS's <code>urlArgs</code> config option. I doubt actually renaming files to contain the timestamp would be feasible, it would complicate build and RequireJS configuration a lot and would most likely require hacks for either development or production. So, in logical order:</p> <ol> <li><p>in pom.xml:</p> <pre><code>&lt;properties&gt; (...) &lt;build.version&gt;${maven.build.timestamp}&lt;/build.version&gt; &lt;/properties&gt; </code></pre></li> <li><p>in the main JSP file:</p> <pre><code>&lt;script type="text/javascript"&gt; var require = { (...) urlArgs: 'v=${build.version}', }; &lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="style.css?v=${build.version}"&gt;&lt;/link&gt; &lt;script data-main="app" src="libs/require.js?v=${build.version}"&gt;&lt;/script&gt; </code></pre> <p><em>It's important to define the <code>require</code> object <strong>before</strong> the require.js import to make urlArgs work</em></p></li> <li><p>pom.xml, again:</p> <pre><code>&lt;resources&gt; (...) &lt;resource&gt; &lt;targetPath&gt;${project.build.directory}/filteredWebapp&lt;/targetPath&gt; &lt;directory&gt;src/main/webapp&lt;/directory&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;/resource&gt; &lt;/resources&gt; </code></pre></li> <li><p>r.js's buildconfig (btw. I'm using <a href="https://stackoverflow.com/a/11553919/1240557">requirejs-maven-plugin</a> to bridge Maven and r.js):</p> <pre><code>({ appDir: '${project.build.directory}/filteredWebapp', dir: '${project.build.directory}/${project.build.finalName}', (...) }) </code></pre> <p>I had to store result of filtering src/main/webapp in a new folder (ie. <code>filteredWebapp</code>) to make sure r.js' input will already contain the build timestamp and not the placeholders. My initial version of r.js buildconfig was reading the source files directly from src/main/webapp; that worked OK but was bypassing maven filtering (ie. output compiled by r.js still contained the <code>${build.timestamp}</code> placeholders)</p></li> </ol> <p>Note: it's probably tricky to configure the development version to use this mechanism (if possible at all, I haven't tried). For me the presence of "v=${build.timestamp}" parameter and lack of cache busting was not a problem in practice, though.</p> <p>There were many other obstacles and pitfalls along the way but I'm assuming you managed to solve those since you're only specifically asking for fingerprinting. Hope that helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload