mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 299031 - heuristic cache rule for 410 should be longer r=mayhemer
This commit is contained in:
parent
482148eedc
commit
bf11c35c29
@ -442,6 +442,14 @@ nsHttpResponseHead::ComputeFreshnessLifetime(uint32_t *result) const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// These responses can be cached indefinitely.
|
||||
if ((mStatus == 300) || (mStatus == 410) || nsHttp::IsPermanentRedirect(mStatus)) {
|
||||
LOG(("nsHttpResponseHead::ComputeFreshnessLifetime [this = %p] "
|
||||
"Assign an infinite heuristic lifetime\n", this));
|
||||
*result = uint32_t(-1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Fallback on heuristic using last modified header...
|
||||
if (NS_SUCCEEDED(GetLastModifiedValue(&date2))) {
|
||||
LOG(("using last-modified to determine freshness-lifetime\n"));
|
||||
@ -453,13 +461,7 @@ nsHttpResponseHead::ComputeFreshnessLifetime(uint32_t *result) const
|
||||
}
|
||||
}
|
||||
|
||||
// These responses can be cached indefinitely.
|
||||
if ((mStatus == 300) || nsHttp::IsPermanentRedirect(mStatus)) {
|
||||
*result = uint32_t(-1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
LOG(("nsHttpResponseHead::ComputeFreshnessLifetime [this = %x] "
|
||||
LOG(("nsHttpResponseHead::ComputeFreshnessLifetime [this = %p] "
|
||||
"Insufficient information to compute a non-zero freshness "
|
||||
"lifetime!\n", this));
|
||||
|
||||
@ -485,6 +487,8 @@ nsHttpResponseHead::MustValidate() const
|
||||
case 304:
|
||||
case 307:
|
||||
case 308:
|
||||
// Gone forever
|
||||
case 410:
|
||||
break;
|
||||
// Uncacheable redirects
|
||||
case 303:
|
||||
|
@ -13,6 +13,7 @@ var longexpPath = "/longexp/" + suffix;
|
||||
var longexp2Path = "/longexp/2/" + suffix;
|
||||
var nocachePath = "/nocache" + suffix;
|
||||
var nostorePath = "/nostore" + suffix;
|
||||
var test410Path = "/test410" + suffix;
|
||||
|
||||
// We attach this to channel when we want to test Private Browsing mode
|
||||
function LoadContext(usePrivateBrowsing) {
|
||||
@ -257,8 +258,17 @@ var gTests = [
|
||||
Ci.nsIRequest.VALIDATE_NEVER,
|
||||
false, // expect success
|
||||
false, // read from cache
|
||||
false), // hit server
|
||||
|
||||
new Test(httpBase + test410Path, 0,
|
||||
true, // expect success
|
||||
false, // read from cache
|
||||
true), // hit server
|
||||
new Test(httpBase + test410Path, 0,
|
||||
true, // expect success
|
||||
true, // read from cache
|
||||
false) // hit server
|
||||
];
|
||||
];
|
||||
|
||||
function run_next_test()
|
||||
{
|
||||
@ -271,7 +281,7 @@ function run_next_test()
|
||||
test.run();
|
||||
}
|
||||
|
||||
function handler(metadata, response) {
|
||||
function handler(httpStatus, metadata, response) {
|
||||
gHitServer = true;
|
||||
try {
|
||||
var etag = metadata.getHeader("If-None-Match");
|
||||
@ -282,7 +292,7 @@ function handler(metadata, response) {
|
||||
// Allow using the cached data
|
||||
response.setStatusLine(metadata.httpVersion, 304, "Not Modified");
|
||||
} else {
|
||||
response.setStatusLine(metadata.httpVersion, 200, "OK");
|
||||
response.setStatusLine(metadata.httpVersion, httpStatus, "Useless Phrase");
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
response.setHeader("ETag", "testtag", false);
|
||||
const body = "data";
|
||||
@ -292,28 +302,32 @@ function handler(metadata, response) {
|
||||
|
||||
function nocache_handler(metadata, response) {
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
handler(metadata, response);
|
||||
handler(200, metadata, response);
|
||||
}
|
||||
|
||||
function nostore_handler(metadata, response) {
|
||||
response.setHeader("Cache-Control", "no-store", false);
|
||||
handler(metadata, response);
|
||||
handler(200, metadata, response);
|
||||
}
|
||||
|
||||
function test410_handler(metadata, response) {
|
||||
handler(410, metadata, response);
|
||||
}
|
||||
|
||||
function shortexp_handler(metadata, response) {
|
||||
response.setHeader("Cache-Control", "max-age=0", false);
|
||||
handler(metadata, response);
|
||||
handler(200, metadata, response);
|
||||
}
|
||||
|
||||
function longexp_handler(metadata, response) {
|
||||
response.setHeader("Cache-Control", "max-age=10000", false);
|
||||
handler(metadata, response);
|
||||
handler(200, metadata, response);
|
||||
}
|
||||
|
||||
// test spaces around max-age value token
|
||||
function longexp2_handler(metadata, response) {
|
||||
response.setHeader("Cache-Control", "max-age = 10000", false);
|
||||
handler(metadata, response);
|
||||
handler(200, metadata, response);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
@ -322,6 +336,7 @@ function run_test() {
|
||||
httpserver.registerPathHandler(longexp2Path, longexp2_handler);
|
||||
httpserver.registerPathHandler(nocachePath, nocache_handler);
|
||||
httpserver.registerPathHandler(nostorePath, nostore_handler);
|
||||
httpserver.registerPathHandler(test410Path, test410_handler);
|
||||
|
||||
run_next_test();
|
||||
do_test_pending();
|
||||
|
Loading…
Reference in New Issue
Block a user