From 87573741f99501b228113cea6e1f23b8e6ffe362 Mon Sep 17 00:00:00 2001 From: Jonas Finnemann Jensen Date: Mon, 31 Oct 2016 10:04:58 -0700 Subject: [PATCH 1/2] Add support for x-taskcluster-skip-cache header --- src/artifacts.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/artifacts.js b/src/artifacts.js index 8cbb6a56..c9b0d7e1 100644 --- a/src/artifacts.js +++ b/src/artifacts.js @@ -356,6 +356,9 @@ var replyWithArtifact = async function(taskId, runId, name, req, res) { if (!region) { debug('artifact from CDN for ip: %s', req.headers['x-forwarded-for']); url = this.publicBucket.createGetUrl(prefix); + } else if (req.headers['x-taskcluster-skip-cache'] === 'true') { + // Skip cache and go to cloud-front + url = this.publicBucket.createGetUrl(prefix); } else if (this.artifactRegion === region) { url = this.publicBucket.createGetUrl(prefix, true); } else { @@ -446,6 +449,13 @@ api.declare({ 'stored externally. Either way, the response may not be JSON. So API', 'client users might want to generate a signed URL for this end-point and', 'use that URL with a normal HTTP client.', + '', + '**Caching**, artifacts may be cached in data centers closer to the', + 'workers in-order to reduce bandwidth costs. This can lead to response', + 'times at upwards 30 seconds. Caching can be skipped by setting the header', + '`x-taskcluster-skip-cache: true`, this should only be used for resources', + 'where request volume is known to be extremely low.', + '(This feature may be disabled in the future, use is sparingly!)', ].join('\n'), }, async function(req, res) { var taskId = req.params.taskId; From c85661f31f9958bb2634d292445709708e198eed Mon Sep 17 00:00:00 2001 From: Jonas Finnemann Jensen Date: Fri, 11 Nov 2016 13:22:26 -0800 Subject: [PATCH 2/2] Addressed review comments from jhford --- src/artifacts.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/artifacts.js b/src/artifacts.js index c9b0d7e1..f06b8a72 100644 --- a/src/artifacts.js +++ b/src/artifacts.js @@ -353,10 +353,11 @@ var replyWithArtifact = async function(taskId, runId, name, req, res) { var bucket = artifact.details.bucket; if (bucket === this.publicBucket.bucket) { + let skipCacheHeader = (req.headers['x-taskcluster-skip-cache'] || '').toLowerCase(); if (!region) { debug('artifact from CDN for ip: %s', req.headers['x-forwarded-for']); url = this.publicBucket.createGetUrl(prefix); - } else if (req.headers['x-taskcluster-skip-cache'] === 'true') { + } else if (skipCacheHeader === 'true' || skipCacheHeader === '1') { // Skip cache and go to cloud-front url = this.publicBucket.createGetUrl(prefix); } else if (this.artifactRegion === region) { @@ -451,10 +452,10 @@ api.declare({ 'use that URL with a normal HTTP client.', '', '**Caching**, artifacts may be cached in data centers closer to the', - 'workers in-order to reduce bandwidth costs. This can lead to response', - 'times at upwards 30 seconds. Caching can be skipped by setting the header', + 'workers in-order to reduce bandwidth costs. This can lead to longer', + 'response times. Caching can be skipped by setting the header', '`x-taskcluster-skip-cache: true`, this should only be used for resources', - 'where request volume is known to be extremely low.', + 'where request volume is known to be low, and caching not useful.', '(This feature may be disabled in the future, use is sparingly!)', ].join('\n'), }, async function(req, res) {