Free Support Forum - groupdocs.com

Reconstruct cache after update on original PDF file

Hi.


How can I force an update on cache files after updating a file that I want to be opened on GroupDocs.Annotation?

I’m having the following problem:
  1. I open a web page that shows a document, for example, /user/documents/file.pdf, on a built GroupDocs.Annotation viewer
  2. GroupDocs create cache files for the document and the document is opened on GroupDocs viewer
  3. Then, I update the same /user/documents/file.pdf file on filesystem
  4. Without reloading the web page and the Javascript files, I call a Javascript function to open the same file
  5. The document shown on the page is not updated. It shows the version of file.pdf before I updated it
Hello,

Thank you for your request.

Basically the GroupDocs.Annotation library inherits the CacheDataHandler class from the GroupDocs.Viewer library . In your use case you should create js code , which will call this handler on the server side to generate new cache for the changed file and after this you can call js function, which will open the changed file.

For how to use the CacheDataHandler please investigate this article .

If you will have more questions please feel free to contact us.

------------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+

Thank you for your answer.


So, I have read the steps on http://www.groupdocs.com/docs/display/viewerjava/ and created a CustomImageCacheHandler and attached it to my AnnotationHandler through the constructor <span style=“font-family: “Courier New”; font-size: small;”>AnnotationHandler(ServiceConfiguration, Connector, CustomImageCacheHandler).

I overrided pdfExists() method, trying to force the generation of new PDF of my document to be rendered, but it didn’t resolve the problem: an old version of PDF is being shown.

I didn’t understand why you said I have to create JS code. On the server side I know when to regenerate the cache files. So I would use this condition to tell GroupDocs to generate or not new cache for the file. But I don’t know where to put its condition. What methods should override?
Hello,

Basically in the CacheDataHandler has such validation "original file modification date < cache create date" , so if you added the Handler to the AnnotationHandler, then it should regenerate the file cache by itself. But here can be another problem - the browser cache , if you not reloaded the web page, then the browser cache can be used . Could you please recheck the file cache on the server side, after you call your js function to open the same file. If the cache will changed, then we can state that on the web page you see the browser cache each time , if the cache not changed, then you should make sure that your js code will call the correct AnnotationHandler " AnnotationHandler(ServiceConfiguration, Connector, CustomImageCacheHandler) "

We will wait for your results.

----------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+

Hi, Evgen.


I tried to disable the browser cache using this meta tags in conjunction with the creation of CustomCacheDataHandler, but it didn’t work. I think that, because of the same generated URL to invoke the servlets the browser is using cache. Ex.: localhost

I think that this occurs because the GroupDocsPath (EncodedPath) is always the same for the same filepath – in this case, is “ub”.

So, I tried to delete the cache folder for only this document on server side, before the response of the request to the web page. Incredibly, it didn’t work, too. New cache files are generated correctly, but the browser shows the older cache files.

But here I create a symbolic link to access a file. The files I visualize with GroupDocs have their extensions modified, so I have to create a symbolic link to pass it to GroupDocs. Then, the solution to my problem were create a symbolic link with new filenames on each request, even if the requested documet is the same. This solved my problem.
Hello Rafael,

We glad to hear that you have solved the cache issue. If you will have more questions please feel free to contact us.

--------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+