We run PDF.js Express 7.1.0 and have a question about cache busting.
Our servers are set to browser cache all static assets for a long time and some assets are even loaded from CDN servers to speed up and cache even more.
However, this also brings us a problem with PDF.js Express since we have core & ui & legacy-ui folders copied from NPM to our public folder, however PDF.js Express does not add any query parameters to the request of these files which would serve older versions of those files to users once we upgrade PDF.js Express, and that would be a shame ofcourse since that could possibly break the web viewer.
It would be great if PDF.js Express would append ?v=7.1.0 (when the version is 7.1.0) to all static assets that are being included, or allow us to supply a version number to append to each url.
Other option would be to not host it at site.com/pdfjsexpress/ui but at site.com/pdfjsexpress/7.1.0/ui however I am not sure I can get NPM to export it like that.
Hope to hear how others have solved this or if there is a “official” suggestion on how to solve this.
We usually recommend that you change the name of the folder the assets are stored in.
So if you were using version 7.0 your assets would live in yourwebsite.com/7.0/lib. When upgrading to 7.1 you would change that to yourwebsite.com/7.1/lib.
You would just have to change the script you are using to copy these files to include the version number in the path.
This should move the required files to ./public/js/pdfjsexpress/7.1.0 when version 7.1.0 is installed.
We have the version pinned to 7.1.0 (or whatever version we want) and we repeat that version number in our application config so we can use the version number when referencing the files in the HTML output.