...

View Full Version : Prevent Caching??



doubledee
10-04-2012, 01:27 AM
Is there a way to prevent images (or content) from being cached on a user's computer?


Debbie

felgall
10-04-2012, 03:27 AM
The simplest way to do that if you have access to a server side language is to simply add a header to tell the browser not to cache the file.

patryk
10-04-2012, 06:12 PM
without getting into setting headers, you can add different GET data each time image is downloaded.
for example if url of image is http://example.com/pic.png, you can access it using http://example.com/pic.png?q=1, http://example.com/pic.png?q=2, http://example.com/pic.png?q=3, and so on.
this way each rime you have diferent url, and browser will download image every time

doubledee
10-07-2012, 07:24 PM
The simplest way to do that if you have access to a server side language is to simply add a header to tell the browser not to cache the file.

Okay, some follow up questions...

1.) How reliable is that?

2.) Will it work equally well in any Server-side Language (e.g. .Net, PHP, etc.)?

3.) Will it work equally well across Browsers (e.g. Internet Explorer, FireFox, Chrome, etc.)?

Thanks,


Debbie

doubledee
10-07-2012, 07:26 PM
without getting into setting headers, you can add different GET data each time image is downloaded.
for example if url of image is http://example.com/pic.png, you can access it using http://example.com/pic.png?q=1, http://example.com/pic.png?q=2, http://example.com/pic.png?q=3, and so on.
this way each rime you have diferent url, and browser will download image every time

So the browser will download a different image every time, but isn't the last/original image still being stored in your browser's cache??


Debbie

patryk
10-07-2012, 08:32 PM
If you'll use URL method, most browser will cache images and discard them when you leave page. That's true also for files with no-cache headers (browser need to have images to display them afterall).
Usually purpose of disabling caching is to display several dynapically generated images with the same url on one page and in that case both methods would work.

maybe i can give you more speciffic info if you'll tell why you want to prevent caching ;)

doubledee
10-07-2012, 09:45 PM
If you'll use URL method, most browser will cache images and discard them when you leave page. That's true also for files with no-cache headers (browser need to have images to display them afterall).
Usually purpose of disabling caching is to display several dynapically generated images with the same url on one page and in that case both methods would work.

maybe i can give you more specific info if you'll tell why you want to prevent caching ;)

I am working on a project where teachers are writing Questions/Answers for a standardized test.

Each teacher logs into the Test Bank over a secure connection, writes their assigned Questions/Answers, it is reviewed and approved by a lead, and then the teacher can no longer view the Questions/Answers.

My client is worried that if a teacher is writing Test Questions/Answers at school or home, and things get cached in their browser or saved some other way (e.g. temp files on Op Sys), then there is an enormous risk that the Test could get into the wrong hands, which would be catastrophic!!!

(It is assumed that teachers are honest and will not save an Web Content or Images themselves.)

I know that you have to download a Web page and Web Images to view them, but is there a way to ensure that the minute a user navigate to a new page, or submits a form, or closes their browser that nothing is left behind in the Browser Cache or Temp Files??

Hope that helps,


Debbie

patryk
10-07-2012, 10:44 PM
In that case changing URLs won't help you at all i'm afraid.
As fare as I know your only option would be to include headers in all images, HTML documents and everything else you can download as teacher.
html:


<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">


or getter yet PHP:


header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');


There's of course autocompletion issue. you probably want to disable that as well ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum