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

AllenJB <[email protected]> Sat, 18 Jan 2025 21:04:52 +0000
Newsgroups gmane.comp.php.general
Message-ID <[email protected]>
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