Open
Bug 775830
Opened 14 years ago
Updated 5 years ago
Cache returns ACCESS_READ descriptor when a ACCESS_READ_WRITE descriptor is requested, if there's already another ACCESS_READ descriptor open for the entry
Categories
(Core :: Networking: Cache, defect, P5)
Core
Networking: Cache
Tracking
()
NEW
People
(Reporter: briansmith, Unassigned)
References
Details
(Whiteboard: [necko-backlog])
When HttpCacheQuery (nsHttpChannel) asks for an ACCESS_READ_WRITE descriptor, the cache returns an ACCESS_READ descriptor if the cache entry already has another descriptor open. In some sense, this makes sense because the entry is already "valid."
However, consider the case where we have a cache entry with "Cache-Control: no-cache." We MUST validate that cache entry every time we use it; however, if we were to try to validate the entry, and we get a non-304 response, then we would not be able to replace the old cached response with the new response from the network.
Currently, HttpCacheQuery (nsHttpChannel) will simply skip re-validation if the cache returns a read-only cache entry, probably specifically to avoid that situation.
Instead, when the caller asks the cache for an ACCESS_READ_WRITE entry, and the cache already has a descriptor for the entry, the cache should wait (NS_ERROR_CACHE_WAIT_FOR_VALIDATION) until the descriptors are closed so that it can always return an ACCESS_READ_WRITE descriptor whenever an ACCESS_READ_WRITE descriptor is requested.
AFAICT, we cannot implement the optimization in bug 767277 until this is done. See that bug for more info.
Comment 1•14 years ago
|
||
(In reply to Brian Smith (:bsmith) from comment #0)
> Currently, HttpCacheQuery (nsHttpChannel) will simply skip re-validation if
> the cache returns a read-only cache entry, probably specifically to avoid
> that situation.
Why we can't revalidate read-only entries? We can still use the entry for validation and simply do not use the entry (and also doom it) in case it is not valid, right? IIRC validation is now done on the cache IO thread, so you could even open a new write-only entry to store the new content after dooming the old one. Write-only request is always non-blocking and can be done synchronously on any non-main thread.
| Reporter | ||
Comment 2•14 years ago
|
||
(In reply to Michal Novotny (:michal) from comment #1)
> (In reply to Brian Smith (:bsmith) from comment #0)
> > Currently, HttpCacheQuery (nsHttpChannel) will simply skip re-validation if
> > the cache returns a read-only cache entry, probably specifically to avoid
> > that situation.
>
> Why we can't revalidate read-only entries? We can still use the entry for
> validation and simply do not use the entry (and also doom it) in case it is
> not valid, right? IIRC validation is now done on the cache IO thread, so you
> could even open a new write-only entry to store the new content after
> dooming the old one. Write-only request is always non-blocking and can be
> done synchronously on any non-main thread.
When the entry is not valid, we will re-validate it (send a conditional request). We have to wait for the server to give us either a 304 response or a non-304 response. In the case of the 304 response we do not need to replace the cache's response body but we need to update the cache headers, so we need write access to update the headers AND read access to read the body. In the case of a non-304 response then we need to be able to replace the cache headers AND replace the cached response body, so I guess we only need write access.
Do you think it would be problematic to change the cache code so that it blocked for ACCESS_READ|ACCESS_WRITE in the same way it blocks for ACCESS_WRITE?
Updated•10 years ago
|
Whiteboard: [necko-backlog]
Comment 3•9 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P1
Comment 4•9 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P1 → P3
Comment 5•5 years ago
|
||
Bulk-downgrade of unassigned, untouched DOM/Storage bug's priority.
If you have reason to believe, this is wrong, please write a comment and ni :jstutte.
Severity: normal → S4
Priority: P3 → P5
You need to log in
before you can comment on or make changes to this bug.
Description
•