Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clean up all cached pages in prerender.io from console
const cleanUp = async () => {
const response = await fetch('https://prerender.io/api/cached-pages?page=0&pageSize=100');
const itemList = await response.json();
const csrfToken = document.cookie.replace(/^.*XSRF-TOKEN=/, '').replace(/;.*$/, '');
const promiseList = itemList.map(item => fetch(`https://prerender.io/api/remove-cached-url?url=${encodeURIComponent(item.url)}`, {
method: 'DELETE',
headers: {
'X-XSRF-TOKEN': csrfToken
}
}));
try {
await Promise.all(promiseList);
}
catch (e) {
console.error(e);
}
setTimeout(cleanUp);
}
cleanUp();
@stonyau

This comment has been minimized.

Copy link

@stonyau stonyau commented Aug 14, 2018

You have my respect hommie.

@osdiab

This comment has been minimized.

Copy link

@osdiab osdiab commented Jan 6, 2021

If you want to delete all of them as opposed to the first 100 entries, here's my script to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment