Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent browser from caching form fields? [duplicate]

I have a textbox in a form field that gets populated by the user. However currently (in Firefox 10) the user can navigate away from the page, then come back, and the input will be populated with its previous value. I think this creates for a confusing user experience, and would like to prevent it.

Is there a way to do this without manually resetting the value? I have tried changing the response to not cache as well as setting autocomplete='false' with no luck.

like image 574
Igor Avatar asked Mar 06 '12 15:03

Igor


People also ask

How do I stop my browser from caching?

Here's how... When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache.

What is browser caching designed to reduce?

Caching is a feature in web browsing that allows recent web pages to be stored temporally in web browsers. This feature is important because it improves the page load time and reduces browsing costs. It is a resourceful technique that can be used by developers to improve web browsing experience.

Is browser caching secure?

For example, since cache information can contain sensitive data, it has to be protected from unauthorized access. In the case of Web applications, you would need to avoid caching confidential information on the user's browser in order to prevent accessing the data outside the control of the Web application.


2 Answers

Try with autocomplete="off", but it will not work with all browsers

PS: duplicate...

Stop browser from filling textboxes with details

Make page to tell browser not to cache/preserve input values

like image 152
soju Avatar answered Oct 11 '22 07:10

soju


just add simple script in some global JS:

$("form :input").attr("autocomplete", "off"); 
like image 20
A.T. Avatar answered Oct 11 '22 05:10

A.T.