snowseo-beacon.php is a single file with no dependencies. It loads before your application, decides in a few microseconds whether the request is worth reporting, and gets out of the way. Your application code is not touched.
Requires PHP 7.4 or later.
On WordPress, use the SnowSEO plugin instead. It does the same job and adds settings, buffering and a page-cache coverage check.
Setup
1
Put the file on your server
Download
snowseo-beacon.php and place it somewhere outside your web root:2
Load it for every request
Add one line to Then reload PHP-FPM or Apache.
php.ini, your PHP-FPM pool config, or a .htaccess:php.ini
.htaccess
3
Set your site key
Configuration
All optional, read from a constant first and then the environment.
Default exclusions:
/wp-admin, /wp-json, /wp-login.php, /xmlrpc.php, /api/, /graphql, /_next/, /assets/, /static/, /build/, /health, /healthz, /status, /favicon.ico, /robots.txt.
Setting SNOWSEO_BEACON_EXCLUDE replaces that list rather than adding to it.
What it does per request
- Exits immediately for CLI, non-
GET/HEADrequests, and anything from a browser. This is the overwhelming majority of traffic and it costs a handful of array lookups. - For a request that asked for Markdown or carried no
Sec-Fetch-*header, checks the path is a page route and not excluded. - Registers a shutdown function, so nothing happens until your response is already produced.
- Calls
fastcgi_finish_request()where available, so the visitor’s connection is closed before the report is sent. On PHP-FPM and LiteSpeed this means zero added latency. - POSTs the hit with a 2-second timeout, swallowing every error.
High-traffic sites
The standalone client sends one request per reportable hit, because plain PHP has nowhere to keep a buffer between requests. Since ordinary visitor traffic is filtered out before this point, that is crawler-only volume and fine for almost every site. Above roughly ten crawler hits per second you will want batching. Either front the site with a Node runtime and use@snowseo/beacon, or get in touch about the APCu-buffered variant.
