Skip to content

Instantly share code, notes, and snippets.

@yjaaidi
Forked from imevro/gist:edfe9dea12196056467f
Last active February 1, 2022 17:01
Show Gist options
  • Save yjaaidi/22f88156ab8094ee3f2efcac298d37cc to your computer and use it in GitHub Desktop.
Save yjaaidi/22f88156ab8094ee3f2efcac298d37cc to your computer and use it in GitHub Desktop.
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();
@osdiab
Copy link

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