How do I use the Prerender.io recache script to refresh multiple URLs?
Trigger fresh renders for hundreds or thousands of URLs at once by sending batches directly to the Prerender.io recache API using a Python script.
TL;DR
The Prerender.io recache script is a Python utility that reads URLs from a text file or XML sitemap and sends them to the Prerender.io recache API in batches of up to 1,000 at a time. You run it from the command line with your Prerender.io token, an input source, and an optional rendering target (desktop or mobile).
Step 1: Copy your Prerender.io token.
Every request the script makes is authenticated with your Prerender.io token. Copy it before running anything.
- Open your Prerender.io dashboard.
- Go to Security & Access → Prerender Token.
- Copy the token value. You will pass it as the first argument when you run the script.
⚠️ Keep your token private. Do not commit it to source control or include it in public forum posts.
Step 2: Download the recache script.
Download the Python script and save it to a working directory on your machine.
ℹ️ Not sure whether the script is the right approach for your setup? Ask Nexus, your AI integration assistant, inside your Prerender.io dashboard. Describe what you are trying to update and Nexus will recommend the best path forward.
Step 3: install the required dependencies.
The script requires Python 3 and the requests library. The xml.etree.ElementTree module is included in Python's standard library and does not need a separate installation.
Check or install Python 3
If you do not already have Python 3, download it from python.org. Verify your installation:
python3 --version
Install the requests library
pip install requests
Step 4: Run the script.
Run the script from your terminal using the format below. Replace YOUR_TOKEN with the token you copied in Step 1.
python RecacheAPI_Script.py YOUR_TOKEN --input_file [FILE_PATH] --sitemap [SITEMAP_URL] --adaptive_type [TYPE]
Arguments
| Argument | Required | Description |
|---|---|---|
YOUR_TOKEN |
Yes | Your Prerender.io token from Step 1. |
--input_file |
One of the two | Path to a .txt file containing one URL per line. |
--sitemap |
One of the two | Full URL of your XML sitemap, e.g. https://example.com/sitemap.xml. |
--adaptive_type |
Optional | desktop (default) or mobile. To cache both versions, run the script twice. |
Use either --input_file or --sitemap per run, not both.
Example: recache from a text file
python RecacheAPI_Script.py YOUR_TOKEN --input_file urls.txt --adaptive_type desktop
Example: recache from a sitemap
python RecacheAPI_Script.py YOUR_TOKEN --sitemap https://example.com/sitemap.xml --adaptive_type mobile
ℹ️ The script sends URLs in batches of 1,000, which is the API's batch limit. If your source contains more than 1,000 URLs, the script processes them in batches of 1,000. Check the terminal output to confirm all batches completed successfully.
⚠️ This script is provided "as is" without warranty of any kind. Use it at your own risk. Prerender.io is not responsible for data loss or service interruptions arising from its use.
Step 5: Verify the recache completed.
After the script finishes, confirm that Prerender.io has processed the URLs.
- Open your Prerender.io dashboard.
- Find the submitted URLs in your cached pages list.
- Check that the Content Age timestamp reflects the current run.
✅ The recache was successful when your submitted URLs appear in Cache Manager with updated content age.
If pages are missing or the script returned errors, see How do I clear my Prerender.io cache? and How the Cache Manager works for related guidance.
Related articles
💬 Still need help? If the script returns errors, your token is rejected, or URLs are not appearing in the cache, our support team can help you diagnose the issue. → Contact us at support@prerender.io