The Prerender.io middleware that you install on your server will check each request to see if it's a request from a crawler. If it is a request from a crawler, the middleware will send a request to Prerender.io for the static HTML of that page. If not, the request will continue on to your normal server routes. The crawler never knows that you are using Prerender.io since the response always goes through your server.
We currently have middleware written in these languages/frameworks:
Prerender.io officially maintained middleware:
Community maintained middleware:
- Spring (Java)
- ASP.NET MVC (C#)
- Zend Framework2 (PHP)
- Symfony 2 (PHP)
- Laravel (PHP)
- Tornado (Python)
- Django (Python)
- Spray (Scala)
After installing the middleware, test locally by downloading our open source Prerender server:
shell git clone https://github.com/prerender/prerender.git cd prerender npm install node server.js
The default port is 3000. Change the server port with export PORT=1337 if needed.
Now you should have a Prerender server running and you should be able to go to
http://localhost:3000/https://www.google.com/ and see the Google homepage.
Try switching out Google's URL with your own! Relative links returned in your HTML (like css) don't display correctly here, but will be fine once proxied through your server.
Testing your middleware:
Make sure to set your middleware's prerenderServiceUrl to point to
http://localhost:3000/ instead of our hosted service. To see a prerendered page exactly how the crawlers will see it, you can set your User Agent in your browser to Googlebot and visit your URL, or run this on a command line and change www.example.com to your URL:
shell curl -A Googlebot https://www.example.com/
That's it! Don't forget to add your Prerender Token to your middleware and push it to a staging server so you can test it with our hosted service.