ATTENTION: this is not a cache problem, not a server configuration and a browser problem. After a thorough study, I found that the problem is related to the problem in my code: Deep, my select request, which fills the fields, precedes my update request, forcing the form to always show values before updating. After the reboot, of course, new updated values will appear, because of which I will look in the wrong direction.
However, this question shows a good overview of all the possible solutions related to the caching problem.
I am creating an application on which there are forms filled with values from a database. The user can change the input values of the form. After sending (not via AJAX), the new values are saved in the database. And again the same form is displayed, this time containing the new values loaded directly from the database. However: my browser (Chrome v27.0.1453.116m on Windows 7) caches old values. New values are displayed only when you redirect to my page.
<form id="edit_form" class="form" action="http://the.same.url/" method="post"> <input type="text" name="example" value="<?php echo $value_from_database; ?>" /> </form>
I came across several solutions, none of which solved the problem:
- Setting the
autocomplete="off" attribute in a form tag: this does not seem to have an effect. - Setting the
autocomplete="off" attribute for individual input tags: this also does not produce results, even in combination with the above solution - Resetting the form with JavaScript when loading the page: this gives some results, but apparently does not affect the radio buttons and others.
- Preventing page caching through meta tags, as suggested here: Using <meta> tags to disable caching in all browsers? Also preventing caching via .htaccess or php headers has no effect.
- Trying to cache by adding a random number to the action url as suggested below by comment by Miro Marcarian
Below is an overview of the proposed solutions: Make a page to tell the browser not to cache / save input values
What are my options? If possible, I would like to avoid asynchronously placing my form. It starts to look like I have no other choice. Any input is appreciated.
Please note that this behavior also appears in other browsers such as IE10.
The name of my page matches the value of one of the inputs in my form and also does not change when sending a new value, so we can determine that this is a caching problem.
The Google Chromes web developers plugin shows me the following headers:
Pragma: no-cache Date: Sun, 30 Jun 2013 09:44:12 GMT Content-Encoding: gzip Vary: Accept-Encoding Server: Apache Transfer-Encoding: chunked Content-Type: text/html; charset=utf-8 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Connection: Keep-Alive Keep-Alive: timeout=15, max=100 Expires: Thu, 19 Nov 1981 08:52:00 GMT 200 OK