Skip to content
  • There are no suggestions because the search field is empty.

How do I use the Prerender recache script to refresh multiple URLs?

Use the Python-based recache script to send large batches of URLs (via file or sitemap) to the Prerender API and trigger re-caching.

If you are new to using Prerender and/or would like to add your URLs quickly from a list or sitemap, you can use our recache API endpoint or the Python script below. This script sends 1000 URL batches of URLs (API
limitation) to the Prerender.io recache API. It can fetch URLs from a sitemap or text file and allows you to specify the rendering device (desktop or mobile). 

API Access Update
Please note that API access is a premium feature available exclusively with our Advanced and Custom/Enterprise plans. For more information or to upgrade your plan, please get in touch with us.

See the guide below on how to use the script. 

1. Download the Python script below:

 

2. Check and install the requirements

  • This is a Python script, which means you will need to install Python3 to run it.  
  • The script uses the requests module, so you will need to run this command to install it: pip install requests
  • The script uses the xml.etree.ElementTree module so you will need to run this command to install it: pip install xml.etree.ElementTree

3. Run the script

To run a Python script, type 'Python' followed by the name of the script. When running the script, make sure to add your Prerender.io Token which can be found in the Security and Access menu.

Next, specify whether you want to process a text file list of URLs (--input_file) or crawl an XML sitemap (--sitemap). You will need to provide the location of your list file or the sitemap's URL as a parameter respectively.

Optionally, you can also specify whether you want to cache the desktop or mobile version of the pages. If you don't specify, the script will request the desktop version. You can't do both at the same time. If you want to cache both versions, you need to run the script twice.

python RecacheAPI_Script.py PRERENDER_TOKEN --input_file [FILE_PATH] --sitemap [SITEMAP_URL] --adaptive_type [TYPE]
Disclaimer
Please note that this script is provided "as is" without warranty of any kind, either express or implied. Users should use this script at their own risk. The author is not responsible for any consequences arising from the use of this script, including but not limited to data loss, system damage, or violation of third-party rights.
 

Overview

When managing a large website or initiating a content refresh, it’s often necessary to re-cache multiple pages quickly. The Prerender recache script allows you to send batches of up to 1000 URLs directly to the recache API using a Python script.

You can pull URLs from a plain text file or an XML sitemap, and optionally specify the rendering target (desktop or mobile). This is ideal for bulk cache updates after major deployments or SEO fixes.

Note: API access is a premium feature, available only on Advanced or Custom/Enterprise plans.

Possible Causes / Scenarios

  • You’ve deployed major site updates and want search engines to see updated content immediately.
  • You’re running SEO experiments and need a clean re-cache for a group of strategic pages.
  • You want to schedule regular cache refreshes across your site using an automated tool.

Solution Steps / Troubleshooting Guide

Step 1: Download the Python Script

Download the recache script using the link below:

RecacheAPI_Script.pyRecacheAPI_Script.py

Step 2: Check and Install Script Requirements

Before using the script, ensure the required libraries and Python version are installed.

  • This is a Python 3 script. If you don’t already have Python 3, download and install Python 3.
  • Install the requests module:
    pip install requests
  • Install the xml.etree.ElementTree module:
    pip install xml.etree.ElementTree

Step 3: Run the Script

Once requirements are installed, run the script using the following format:

python RecacheAPI_Script.py PRERENDER_TOKEN --input_file [FILE_PATH] --sitemap [SITEMAP_URL] --adaptive_type [TYPE]

Details:

  • PRERENDER_TOKEN: Your Prerender API token (found in the Security & Access menu)
  • --input_file: (Optional) The file path of a .txt file containing one URL per line
  • --sitemap: (Optional) The full URL of your sitemap (e.g., https://example.com/sitemap.xml)
  • --adaptive_type: Set to desktop or mobile depending on which version you want cached

You only need to use one of the following at a time: --input_file or --sitemap. To cache both desktop and mobile versions, run the script twice with different values for --adaptive_type.

Example:

python RecacheAPI_Script.py PRERENDER_TOKEN --input_file urls.txt --adaptive_type desktop

Additional Tips / Best Practices

  • Don’t run too many instances of the script at once—stick to one session per site or environment.
  • Check your rate limits if you're using a very large sitemap or multiple files.
  • Group URLs by importance or business priority if you plan to recache in stages (e.g., /blog/* vs /product/*).

When to Contact Support

If the script fails to process or returns errors:

  • Send the command you’re using (with token and paths redacted)
  • Mention the error message received or copy the terminal output from the failed run
  • Email us at support@prerender.io

Related Articles / FAQs


Disclaimer:
This script is provided “as is” without warranty of any kind, express or implied. Use it at your own risk. We are not responsible for data loss, service interruptions, or legal consequences from using or sharing this tool.