In the process of generating presigned URLs for uploading to S3, it is necessary to set the Cache-Control
header value to be
public, max-age=31536000, immutable
.
The fetch operation is executed using the following code:
fetch(
uploadUrl,
{
method: 'PUT',
cache: 'no-store',
headers: { 'Content-Type': contentType, 'Cache-Control': 'public, max-age=31536000, immutable' },
body: data
})
.then(response => {
if (response.ok) {
doneFunc(publicUrl);
} else {
failureFunc(response.status);
}
})
.catch(response => {
failureFunc(response.status);
});
When making a PUT request in Chrome, the Cache-Control
header included in the fetch call is accurately preserved as
public, max-age=31536000, immutable
.
In contrast, when the PUT request is made in Firefox, the Cache-Control
header includes an extra parameter, specifically
public, max-age=31536000, immutable, no-cache
. This unexpected addition causes issues with the validity of the presigned URL.
Attempts to remove or modify the cache parameter including setting it to no-cache
or no-store
have not been successful in preventing Firefox from appending additional parameters to the Cache-Control
header.
Is there a solution to ensure that Firefox behaves consistently with Chrome and respects the originally set headers?