mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
js client: Etag-related invalidation fixes [#90]
This commit is contained in:
@@ -282,6 +282,9 @@ export class FetchSource implements Source {
|
|||||||
headers: { Range: "bytes=" + offset + "-" + (offset + length - 1) },
|
headers: { Range: "bytes=" + offset + "-" + (offset + length - 1) },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// can return 416, which will have a blank etag on S3.
|
||||||
|
// See https://github.com/protomaps/PMTiles/issues/90
|
||||||
|
|
||||||
if (resp.status >= 300) {
|
if (resp.status >= 300) {
|
||||||
throw Error("404");
|
throw Error("404");
|
||||||
controller.abort();
|
controller.abort();
|
||||||
@@ -858,7 +861,7 @@ export class PMTiles {
|
|||||||
return await this.getZxyAttempt(z, x, y, signal);
|
return await this.getZxyAttempt(z, x, y, signal);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof EtagMismatch) {
|
if (e instanceof EtagMismatch) {
|
||||||
this.cache.invalidate(this.source, e.name);
|
this.cache.invalidate(this.source, e.message);
|
||||||
return await this.getZxyAttempt(z, x, y, signal);
|
return await this.getZxyAttempt(z, x, y, signal);
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -886,7 +889,7 @@ export class PMTiles {
|
|||||||
return await this.getMetadataAttempt();
|
return await this.getMetadataAttempt();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof EtagMismatch) {
|
if (e instanceof EtagMismatch) {
|
||||||
this.cache.invalidate(this.source, e.name);
|
this.cache.invalidate(this.source, e.message);
|
||||||
return await this.getMetadataAttempt();
|
return await this.getMetadataAttempt();
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
Reference in New Issue
Block a user