npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

express-static-angular-seo

v1.0.0

Published

A simple reverse proxy that takes any URL and uses PhantomJS to fetch a version that has the JavaScript executed. Set the Host HTTP header to use this for more than one domain.

Downloads

4

Readme

express-static-angular-seo

A simple reverse proxy that takes any URL and uses PhantomJS to fetch a version that has the JavaScript executed. Set the Host HTTP header to use this for more than one domain.

This app listens on port 8888 by default, it can be changed by setting the environment variable NODE_PORT.

When loading is done on your webpage (all XHR, rendering, etc), you should call

if(typeof window.callPhantom === "function") {
	window.callPhantom({rendered: true});
}

Or if you prefer coffeescript

if typeof window.callPhantom is "function"
	window.callPhantom rendered: true

Angular.js

If you are using angular.js, you can use my module angular-static-seo. Instructions are on that readme.

Nginx Setup

You can setup nginx to automatically send Google, Facebook, Twitter, etc to the pre-rendered versions. Nginx can also automatically cache the results:

nginx.conf

...
http {
	...
	# caching options
	proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=node_express_cache:8m max_size=1000m inactive=600m;
	proxy_temp_path /var/cache/tmp;

	server_names_hash_bucket_size 64;
	...
}

sites-enabled/demo

upstream node_express {
    server localhost:9000;
}

upstream express_static_angular_seo {
	server localhost:8888;
}

server {
	listen 80;

	access_log on;
	error_log on;

	root /www/var/express/public;
	index index.html;

	server_name example.com;

	set $is_bot '0';

	if ($http_user_agent ~ '(facebookexternalhit|googlebot|bingbot|twitterbot|teoma|Baiduspider)') {
		set $is_bot '1';
	}

	location / {
		add_header X-Bot $is_bot;

		proxy_cache node_express_cache;

		proxy_redirect off;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_cache_key "$scheme$host$request_uri$is_bot";

		proxy_cache_valid 1d;

		add_header X-Cached $upstream_cache_status;

		proxy_pass http://node_express;
		if ($is_bot = '1') {
			proxy_pass http://express_static_angular_seo;
		}
	}
}

Clearing/purging the cache

find /var/cache/nginx/ -type f -delete
service nginx restart

Restarting nginx is important after clearing the cache.