I am working on a site locally, which has a lot of <textarea>
elements.
However, everytime I reload the site the content in the <textarea>
is still there. This only happens when I hit reload / F5.
What can I do to stop the site from being cached, without using any in-browser functions.
I am looking for a solution within the site, so when other users in my office opens it, they won't have the same problem.
I am working on a site locally, which has a lot of <textarea>
elements.
However, everytime I reload the site the content in the <textarea>
is still there. This only happens when I hit reload / F5.
What can I do to stop the site from being cached, without using any in-browser functions.
I am looking for a solution within the site, so when other users in my office opens it, they won't have the same problem.
Share Improve this question edited May 30, 2013 at 13:14 Flimm 151k49 gold badges274 silver badges286 bronze badges asked Jan 4, 2012 at 15:30 Maximilian LindseyMaximilian Lindsey 8494 gold badges19 silver badges36 bronze badges 2- On windows there's ctrl+f5 or something like that that clears the cache when it reloads the site. – CamelCamelCamel Commented Jan 4, 2012 at 15:33
- That's supposed to happen, so you don't lose any data entered into form fields when the page is reloaded for whatever reason. It's not "cached", but is remembered by the browser as a convenience. As far as I know, the only way to prevent it is to change the field's name so FF thinks it's a 'new' field and doesn't restore the previous content. – Marc B Commented Jan 4, 2012 at 15:33
3 Answers
Reset to default 16You can disable it in your html by setting the autocomplete attribute to off:
<input name="whatever" type="text" autocomplete="off">
You could also disable it for the entire form:
<form name="form1" id="form1" method="post" autocomplete="off">
https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
You might like the Webdeveloper Toolbar for Firefox. https://addons.mozilla.org/en-US/firefox/addon/web-developer/
With this toolbar you can easily disable caching, clear cookies, clear form data, disable javascript and much more. Might make your life easier :)
You can add some javascript in the head portion of your page to set the textboxes to an empty string. Then in your body onLoad event you call your javascript function which will clear it each time the browser is reloaded.
<html>
<head>
<script type="text/javascript">
function clear()
{
document.getElementById("TextBoxName").value = "";
}
</script>
</head>
<body onLoad="clear()">
....
</body>
</html>
Of course if the user has turned off javascript this function won't work but if it's an internal app you can control those types of settings.