Closed Bug 1555927 Opened 5 years ago Closed 5 years ago

Cacheable Http 204 (No Content) responses to GET request not cached

Categories

(Core :: Networking: Cache, defect, P2)

67 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: frederic.delaporte, Assigned: kershaw)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0

Steps to reproduce:

Have an api which, on a GET request, responds a 204 No Content with a Cache-Control: Public,max-age=1200 directive, no expires, no pragma, no vary.
Query it through a GET ajax call in a Html page.
Query it again identically before expiration (typically by browsing again the page).

Actual results:

Firefox queried the api twice.

Expected results:

Firefox should have not queried the api a second time.

Chrome does just that : query only once, reusing the previous result from cache the second time.
The problem can be reproduced in a new profile.

Component: Untriaged → Networking: Cache
Product: Firefox → Core

Since nsHttpResponseHead::MustValidate returns true when the status is 204, we can't serve the response from the cache entry.

Not sure if we can simply add 204 in nsHttpResponseHead::MustValidate.
Honza, what do you think?

Flags: needinfo?(honzab.moz)

https://tools.ietf.org/html/rfc7231#section-6.3.5

A 204 response is cacheable by default; i.e., unless otherwise
indicated by the method definition or explicit cache controls (see
Section 4.2.2 of [RFC7234]).

we also write it on MDN: 204 No Content - HTTP | MDN

so, yes, we should add 204 to nsHttpResponseHead::MustValidate

Flags: needinfo?(honzab.moz)
Assignee: nobody → kershaw
Priority: -- → P2
Whiteboard: [necko-triaged]
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Oh, I was not aware of that we already have wpt test for 204 response.
I'll fix this.

Flags: needinfo?(kershaw)
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: