You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve had issues with the purge-all task. After some digging, its caused by superagent who makes request with 'Content-Encoding'.
Here is a refactor proposal to use the request package instead. I picked the same version as phantom uses.
diff --git c/lib/tasks/purge-all.js w/lib/tasks/purge-all.js
index 56cecd6..ed42258 100644
--- c/lib/tasks/purge-all.js+++ w/lib/tasks/purge-all.js@@ -1,16 +1,28 @@-var sua = require("superagent");+var request = require("request");
// expects:
// purgeAllURL: the URL to purge Fastly
// purgeAllKey: the key for the Fastly service
module.exports = function (ctx, cb) {
- sua.post(ctx.purgeAllURL)- .set("Fastly-Key", ctx.purgeAllKey)- .set('Accept', 'application/json')- .end(function (err, res) {- if (!err && res.body && res.body.status === "ok") return cb();- cb(new Error(res.body ? res.body.status : "No response body for purge"));- })- ;++ var options = {+ url: ctx.purgeAllURL+ , method: 'POST'+ , headers: {+ 'User-Agent': 'WebPlatformPublican/1'+ , 'Fastly-Key': ctx.purgeAllKey+ }+ };++ return request(options, function requestCallback(error, response, body) {+ var info = JSON.parse(body);+ if (!error && response.statusCode == 200) {+ console.log('Purge worked', info);+ return cb();+ } else {+ cb( new Error('Error purging, message ', info ) );+ }+ });+
};
In package.json;
+ "request": "2.42.0"
My concern about purge all is that its a very powerful thing to do. Maybe I should just adjust the lifetime of items to last a few minutes but set it so that it can remain "stale" for a long period.
This would do what we both want; don’t need to purge every now and then, AND keep the site up even when the servers underneath are down.
The text was updated successfully, but these errors were encountered:
renoirb
added a commit
to webplatform/publican
that referenced
this issue
May 21, 2015
I’ve had issues with the purge-all task. After some digging, its caused by superagent who makes request with 'Content-Encoding'.
Here is a refactor proposal to use the
request
package instead. I picked the same version as phantom uses.In
package.json
;My concern about purge all is that its a very powerful thing to do. Maybe I should just adjust the lifetime of items to last a few minutes but set it so that it can remain "stale" for a long period.
This would do what we both want; don’t need to purge every now and then, AND keep the site up even when the servers underneath are down.
The text was updated successfully, but these errors were encountered: