Re: Is there a pref setting governing caching of async form submissions?

From: Date: Sat, 18 Jan 2025 21:04:52 +0000
Subject: Re: Is there a pref setting governing caching of async form submissions?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-328616@lists.php.net to get a copy of this message
On 18/01/2025 20:13, JEFFRY KILLEN wrote:
So it PHP caching form submissions"?
No. PHP does not cache requests / responses in this manner. The most likely source of caching is the browser itself. There are several ways you can avoid this: 1) Use POST or PUT submission method. In general, by default: GET requests may be cached, POST and PUT (and DELETE) requests are not cached. 2) Append a random value to the query string, which changes with each request. The current (unix) timestamp is a commonly used value since it will always be unique (at least for submission not made in the same second). eg: /form-endpoint?nocache=48738743593 (some client-side libraries, such as JQuery have an option that does this). The server-side doesn't need to do anything with this value, but the fact that it's there makes the browser see each request as a different one from any previous request. 3) Use appropriate HTTP headers (eg. Cache-Control - see links below) Further reading: * https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching * https://developer.mozilla.org/en-US/docs/Glossary/Cacheable

« previous php.general (#328616) next »