I am using pdfexpress JS version 8.7. When I markup the PDF, it is stored successfully to my storage. I am able to see the markup when I download the pdf. But when I markup the pdf again, I see the old pdf and not the updated one.
When I disable the cache from my network tab in element inspector, and then markup again, I can see the updated version. So ultimately it is showing the file from the browser cache instead of latest file.
Could you please help me out to solve this and use the latest file instead of the older one?
I was not able to reproduce the issue where downloading the PDF with added markup reverted to the initial PDF without markup. If you would like to load the PDF with added markup, I suggest exporting annotations with exportAnnotations() which will store the annotation XFDF data and can be later imported on the same document.
Hi @kkim
Thanks for the prompt response. Here exporting the XFDF data is not required. Because we are merging the layers with merge function call. Here issue is the file loading from cache.
When I open element inspector by pressing F12 and go to the network tab, and check the “Disable cache” checkbox, it loads the correct pdf. Kindly watch the video on markup_issue.webm - Google Drive
In the video, the Lorem_ipsum_text1.pdf document loading is using the disk cache when loading the document. This is preventing you to see any changes in the browser.
You can set up cache-busting by changing the URL of the document on every load. For example appending a date stamp: ?nocache=${Date.now()}
Or you can set up caching directives for the browser with Cache-Control headers. More information can be found here: Cache-Control - HTTP | MDN
@kkim Thank you for the quick response. I understood what you are suggesting. But here adding the nocache is not possible at our end. We are using the CDN URL that is working with the tokenization, because of private S3 bucket. So here adding the additional parameter or updating the parameter value in the URL after markup won’t work. If we do so, it will result in 403 error on the URL access. We are using different files like pdf, csv, xls, png, jpg, webm, etc. Other files are working fine on their respective editors. We are facing issue with pdf markup only.
It would be really great if you can suggest some solution that can be applied directly in the code of markup (js code where we are marking up the file using pdfexpress.js).
In that case, I would recommend generating a blob from the URL using URL.createObjectURL() which is always unique and would not cache. More information can be found here: URL: createObjectURL() static method - Web APIs | MDN
Please let me know if you have any other question related to PDFJS as we do not have control or custom options for caching.