This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to clear the browser cache when I close my browser.

 
Ratish Vichithran
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application shows payslips of employees. So when a user click on a link it generates the pdf for which I have added the following code,



But the problem here is that, it creates a PDF in the temporary folder.

Is there a way to delete the cache after the browser showing the pdf is closed?

I tried deactivating cache with the following code,



but it gave me an error saying the file could not be downloaded.


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. The file must be copied to the local system in order to be viewed and there is no setting to cause it to delete itself.
 
Ratish Vichithran
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear Bibeault. Thanks for the reply...

But is there any way to avoid a Cache and also show a pdf using Content-Disposition as inline? . Because it is a security concern. Any other user using the work station can easily access the previous persons data.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. It is the responsibility of the user to keep his data secure.
 
Ratish Vichithran
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok let me put it this way. How will I show a pdf to the user and also adhere to security?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me put it this way: you can't!

If you want to show the file to the user, it must be downloaded to their system. After that, it's their responsibility.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatives:
  • Don't use a PDF or anything that needs to be downloaded to their system. Just show it as a no-cached page.
  • Explore password-protecting the PDF.
  • Don't show it in the broswer at all; send it in email.

  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic