How to use Prerender recache script
  • 23 Jan 2024
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

How to use Prerender recache script

  • Dark
    Light
  • PDF

Article Summary

Prerender Recache Script Documentation

Prerender Recache Script Documentatio<span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span<span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span>

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). 

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 token which can be found on the top right of your Prerender Dashboard.

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.

Was this article helpful?