-
-
Save lincetto/2c117d1b5f26380bb41fee2f1783edbf to your computer and use it in GitHub Desktop.
Clean up all cached pages in prerender.io from console using a search term
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
await import('https://code.jquery.com/jquery-2.2.4.min.js') | |
// Library ready | |
var cleanUp = function() { | |
jQuery.ajax({method: "GET", url: "https://dashboard.prerender.io/api/cached-pages?page=0&pageSize=1000&sort=date"}).success(function(response) { | |
var total = response, | |
lastChecked = 1; | |
console.log("total: " + response.length); | |
for(var i = 0; i < total.length; i++) { | |
jQuery.ajax({ | |
method: "DELETE", | |
url: "https://dashboard.prerender.io/api/remove-cached-urls", | |
data: "{\"urls\":[{\"url\":\"" + total[i].url + "\",\"adaptiveType\":\"desktop\"}]}", | |
contentType: "application/json;charset=UTF-8", | |
headers: { | |
"x-xsrf-token": "<your-token-grabbed-from-a-valid-request>" | |
} | |
}).done(function() { | |
console.log("good, " + (lastChecked + "/" + total.length)) | |
}) | |
} | |
}) | |
} | |
cleanUp() | |
//if you have to remove more than 1k pages, use setInterval | |
//setInterval(function(){ cleanUp(); }, 15000); | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_page = 0; | |
(async () => { | |
await import('https://code.jquery.com/jquery-2.2.4.min.js') | |
// Library ready | |
var cleanUp = function() { | |
console.log("recaching from " + (_page * 1000) + " to " + ((_page+1) * 1000)); | |
jQuery.ajax({method: "GET", url: "https://dashboard.prerender.io/api/cached-pages?page="+_page+"&pageSize=1000&sort=date"}).success(function(response) { | |
var total = response, | |
lastChecked = 1; | |
console.log("total: " + response.length); | |
for(var i = 0; i < total.length; i++) { | |
jQuery.ajax({ | |
method: "POST", | |
url: "https://dashboard.prerender.io/api/v2/cache-page", | |
data: "{\"urls\":[{\"url\":\"" + total[i].url + "\",\"adaptiveType\":\"desktop\"}]}", | |
contentType: "application/json;charset=UTF-8", | |
headers: { | |
"x-xsrf-token": "<your-token-grabbed-from-a-valid-request>" | |
} | |
}).done(function() { | |
console.log("good, " + (lastChecked + "/" + total.length)) | |
}) | |
} | |
}) | |
} | |
cleanUp() | |
//if you have to remove more than 1k pages, use setInterval | |
//setInterval(function(){ cleanUp(); _page += 1; }, 15000); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment