-
-
Save yjaaidi/22f88156ab8094ee3f2efcac298d37cc to your computer and use it in GitHub Desktop.
Clean up all cached pages in prerender.io from console
This file contains hidden or 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
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(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have my respect hommie.