Skip to content

Instantly share code, notes, and snippets.

@muratcorlu muratcorlu/
Last active Apr 14, 2016

What would you like to do?
Prerender Installation to Debian with Nginx Proxy and Caching
# Prerender kurulumu
sudo locale-gen UTF-8
sudo apt-get update
sudo apt-get install -y curl
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs build-essential libfontconfig nginx-extras
sudo npm install -g phantomjs
sudo npm install -g prerender
sudo npm install -g pm2
echo “export LC_ALL=en_US.UTF-8” >> ~/.bashrc
echo “export PRERENDER_NUM_WORKERS=4” >> ~/.bashrc
source ~/.bashrc
sudo dpkg-reconfigure locales
pm2 start prerender
# copy nginx configuration
sudo cp prerender.conf /etc/nginx/sites-enabled/.
sudo /etc/init.d/nginx restart
lua_shared_dict expire_queue 10m;
proxy_cache_path /tmp/nginx/ levels=1:2 keys_zone=default:10m;
server {
listen 80;
location / {
header_filter_by_lua '
if ngx.header["X-Expire-Content"] then
ngx.log(ngx.INFO, "Backend sent invalidation header, adding to the queue " .. ngx.header["X-Expire-Content"])
set_by_lua $http_cache_purge '
local expire = ngx.shared.expire_queue:get(ngx.var.uri)
if expire then
ngx.log(ngx.INFO, "Removing URL from queue and invalidating, " .. ngx.var.uri)
return expire
add_header X-Cached $upstream_cache_status;
proxy_cache_bypass $http_cache_purge;
proxy_cache default;
proxy_cache_valid 200 302 72h;

This comment has been minimized.

Copy link
Owner Author

muratcorlu commented Apr 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.