WeAmp.PageSpeed.NativeAssets.Linux
2.0.21
Prefix Reserved
dotnet add package WeAmp.PageSpeed.NativeAssets.Linux --version 2.0.21
NuGet\Install-Package WeAmp.PageSpeed.NativeAssets.Linux -Version 2.0.21
<PackageReference Include="WeAmp.PageSpeed.NativeAssets.Linux" Version="2.0.21" />
<PackageVersion Include="WeAmp.PageSpeed.NativeAssets.Linux" Version="2.0.21" />
<PackageReference Include="WeAmp.PageSpeed.NativeAssets.Linux" />
paket add WeAmp.PageSpeed.NativeAssets.Linux --version 2.0.21
#r "nuget: WeAmp.PageSpeed.NativeAssets.Linux, 2.0.21"
#:package WeAmp.PageSpeed.NativeAssets.Linux@2.0.21
#addin nuget:?package=WeAmp.PageSpeed.NativeAssets.Linux&version=2.0.21
#tool nuget:?package=WeAmp.PageSpeed.NativeAssets.Linux&version=2.0.21
WeAmp.PageSpeed for ASP.NET Core
Drop-in ASP.NET Core middleware that improves Core Web Vitals without touching your app code. It adds critical CSS inlining, LCP preload injection, lazy loading, and on-demand WebP/AVIF image transcoding to every HTML response. The C++23 PageSpeed engine runs in-process via P/Invoke and serves cache hits zero-copy.
Single-package install. Hot-reloadable config. Optimization runs out of the
box, so you can evaluate it without a license. While unlicensed, responses
carry an X-PageSpeed-Warn: unlicensed header; a commercial license is
required for production use.
Buy or apply a key from the in-app console at /console/ — see plans at
modpagespeed.com/pricing/.
Quick Start
1. Install the package
dotnet add package WeAmp.PageSpeed.AspNetCore
The matching native binaries for your runtime (linux-x64, linux-arm64,
osx-arm64, or win-x64) come in transitively: no separate NativeAssets
package reference required.
2. Register the middleware in Program.cs
using WeAmp.PageSpeed.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddPageSpeed();
var app = builder.Build();
app.UsePageSpeed(); // before anything that writes the response body
app.UseStaticFiles();
app.Run();
No extra wiring required: with no Worker section, the worker process starts
automatically and coordinates over an auto-resolved per-process socket. Add a
Worker section only to change that — see Configuration.
Optimization is on by default; see step 3 to license it for production.
3. License it for production
You can evaluate the middleware right away. For production a commercial license
is required; until one is applied, every response carries an
X-PageSpeed-Warn: unlicensed header and the console shows an unlicensed
notice. To license it, run your app and navigate to
http://<your-app-host>/console/ in a browser, then
buy a subscription — monthly or annual,
billed immediately, cancel anytime. The issued key is applied automatically and
persisted to the cache volume, then reused on subsequent runs. You can also
paste an existing key into the same /console/ page. (/console/ is an admin
surface — see Security before exposing it beyond localhost.)
4. How do I know it's working?
Three checks, from quickest to most thorough. These examples assume your app
listens on :5050 (set ASPNETCORE_URLS=http://localhost:5050 or adjust the
URLs to your port) and serves at least one HTML page and one image.
Hit a content route and look for the X-PageSpeed header:
curl -i http://localhost:5050/
HTTP/1.1 200 OK
X-PageSpeed: HIT
HIT means the response was served from the optimized cache; MISS means the
worker is building the variant and you'll see HIT on the next request. (The
/console/* routes are short-circuited before the middleware, so they
intentionally do not carry X-PageSpeed — only content routes like / and
your assets do.)
Open http://localhost:5050/console/dashboard. Once a few requests have run,
the Dashboard and Metrics show non-zero counts. If everything reads zero, see
How do I know it's working?
in the docs.
Confirm image transcoding via content negotiation. We don't rewrite URLs in
2.0: the same /hero.jpg URL serves WebP to WebP-capable clients and AVIF to
AVIF-capable ones, selected by the request Accept header:
curl -s -o /dev/null -D - http://localhost:5050/hero.jpg -H 'Accept: image/jpeg'
# Content-Length: 98230 Content-Type: image/jpeg Vary: Accept, Save-Data, User-Agent
curl -s -o /dev/null -D - http://localhost:5050/hero.jpg -H 'Accept: image/webp'
# Content-Length: 2422 Content-Type: image/webp Vary: Accept, Save-Data, User-Agent
curl -s -o /dev/null -D - http://localhost:5050/hero.jpg -H 'Accept: image/avif'
# Content-Length: 415 Content-Type: image/avif Vary: Accept, Save-Data, User-Agent
Same URL, materially smaller bytes, and a Vary: Accept, Save-Data, User-Agent
header so caches keep the variants apart. (Byte counts are from one sample
image; yours will differ.)
What It Does
- HTML optimization: critical CSS inlining, lazy loading, LCP preload injection, third-party preconnect hints
- Image transcoding: on-demand conversion to WebP and AVIF, viewport-aware resizing, Save-Data support
- CSS/JS minification: whitespace removal, comment stripping
- Zero-copy caching: cache hits served from the memory-mapped Cyclone cache with no copy, up to 36 optimized variants per resource (format × viewport × density × Save-Data)
The middleware buffers HTML responses, passes them through the native
libpagespeed library, and notifies the worker process to generate optimized
asset variants asynchronously.
Platform Support
| RID | Status | Notes |
|---|---|---|
| linux-x64 | Supported | glibc 2.34+ (RHEL 9 / Ubuntu 22.04 / Debian 12 or newer) |
| linux-arm64 | Supported | glibc 2.34+ |
| osx-arm64 | Supported | macOS 13+ (Apple Silicon) |
| win-x64 | Supported | Windows 10/11, Server 2019+ |
Native binaries (libpagespeed, factory_worker) are bundled with the
matching WeAmp.PageSpeed.NativeAssets.* package, pulled in transitively by
WeAmp.PageSpeed.AspNetCore. The worker process starts automatically on
application boot. The Linux binaries statically link the C++ runtime
(libc++/libc++abi/libunwind), so no additional shared libraries need to be
present on the host beyond the system glibc.
On Linux and want a reverse proxy instead of in-process middleware?
WeAmp.PageSpeed.Sidecar
runs mod_pagespeed 1.15 as a bundled nginx + ngx_pagespeed reverse proxy in front of
Kestrel (Linux-only). Use it when you want the classic nginx module in a sidecar; use
this package for cross-platform in-process optimization with WebP/AVIF.
Each NativeAssets package also ships a BUILD_INFO.json file at
runtimes/<rid>/native/BUILD_INFO.json with git_sha, git_sha_short,
build_timestamp_utc, and rid. It is intended for support correlation —
matching compliance-report heartbeats (which emit the worker's git_commit) to
a specific package build — and for verifying package provenance without running
the worker.
Configuration
Add a PageSpeed section to appsettings.json. Only Cache is shown below;
every key in the table is optional and falls back to its default.
{
"PageSpeed": {
"Cache": {
"VolumePath": "/var/cache/pagespeed/volume.dat",
"VolumeSizeBytes": 1073741824
}
}
}
Set Cache.VolumePath to a location that is writable in your environment. The
default /var/cache/pagespeed/ assumes a Linux host; on Windows, macOS, or
containers without that path, point it somewhere writable (for example
./cache/volume.dat or %TEMP%).
Top-level keys:
| Setting | Default | Description |
|---|---|---|
Enabled |
true |
Enable/disable the middleware (supports hot-reload) |
LicenseKey |
null |
License key (base64url-encoded Ed25519 token) |
ExcludePaths |
["/api/", "/signalr/", "/_blazor/", "/_framework/"] |
URL prefixes the middleware leaves untouched (supports hot-reload) |
CacheMode |
Safe |
Safe: must-revalidate on assets. Aggressive: public + stale-if-error on assets. HTML is always no-cache. |
MaxResponseBufferBytes |
5242880 (5 MB) |
Responses larger than this pass through unmodified |
CssMaxAgeSeconds |
300 |
max-age on CSS/JS cache HIT responses |
ImageMaxAgeSeconds |
1800 |
max-age on image cache HIT responses |
Cache section:
| Setting | Default | Description |
|---|---|---|
Cache.VolumePath |
/var/cache/pagespeed/volume.dat |
Path to the Cyclone cache volume file (must be writable) |
Cache.VolumeSizeBytes |
1073741824 (1 GB) |
Maximum cache volume size |
Worker section:
| Setting | Default | Description |
|---|---|---|
Worker.AutoStart |
true |
Launch and manage the worker process on startup. Set false to run no worker. |
Worker.SocketPath |
unset | Worker-coordination socket. Leave it unset (the default) for an auto-resolved per-process socket with coordination on. Set to a concrete path to share one socket with an out-of-process worker. Setting it to null or "" disables coordination and logs a startup warning. |
Worker.ApiPort |
0 (auto, loopback only) |
Override to expose the worker HTTP API on a fixed port |
Console section:
| Setting | Default | Description |
|---|---|---|
Console.MountPath |
/console |
URL prefix for the in-app console |
Console.RequireHttps |
false |
Reject non-HTTPS requests to the console (set true in production) |
Options support hot-reload via IOptionsMonitor<PageSpeedOptions>.
Worker IPC
The middleware ↔ worker channel uses Unix domain sockets on Linux and macOS,
and Windows Named Pipes on win-x64. Selection is automatic; no configuration
required. The console and license endpoints are served on the app port; the
worker's HTTP API is bound to 127.0.0.1 on an ephemeral port by default and
is not exposed externally unless you set Worker.ApiPort explicitly.
Security
The /console/ admin console and /v1/license/* proxy are served on the same
origin as your app. The worker requires Content-Type: application/json and
X-Requested-With: XMLHttpRequest on POSTs to /v1/license/*, which blocks
cross-origin form posts. It does not protect against same-origin scripts: a
third-party script loaded into your app (via XSS or a supply-chain dependency)
can drive a license POST such as POST /v1/license/apply to install an
attacker-supplied key, because that endpoint is auth-exempt to allow
bootstrapping before an API token is configured.
Treat /console/ as an admin surface:
- Set
Console.RequireHttps = truein production. - Don't expose
/console/to untrusted networks. Gate it at your reverse proxy, or useConsole.MountPathto move the path off a guessable location. - Avoid loading untrusted third-party scripts into apps with this middleware enabled.
License
Licensed under the Business Source License 1.1 (BUSL-1.1).
- Change Date: Four years after the first public release of each version (see the Change Date in the packaged LICENSE file).
- Change License: Apache License 2.0
After the Change Date, each version becomes available under Apache 2.0. See the LICENSE file in the package for full terms.
Links
- modpagespeed.com/pricing/ — plans, pricing, and purchase
- modpagespeed.com/features/#aspnet-core — ASP.NET Core overview
- WeAmp.PageSpeed.Sidecar — mod_pagespeed 1.15 as a bundled-nginx sidecar (Linux)
- modpagespeed.com — product documentation and filter reference
- we-amp.com — We-Amp B.V.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on WeAmp.PageSpeed.NativeAssets.Linux:
| Package | Downloads |
|---|---|
|
WeAmp.PageSpeed
Most ASP.NET Core users want WeAmp.PageSpeed.AspNetCore (the drop-in middleware), which pulls this package as a transitive dependency. This package is the low-level managed binding to the C++23 PageSpeed engine via P/Invoke — install it directly only if you're embedding the optimization library outside of an ASP.NET Core pipeline. Provides HTML transformation, critical CSS extraction, image classification, and high-performance caching. |
GitHub repositories
This package is not used by any popular GitHub repositories.
2.0.21: Package polish. The README is rewritten for accuracy and clarity — the per-resource optimized-variant ceiling is corrected to 36 (format x viewport x density x Save-Data), the security example points at the real auth-exempt /v1/license/apply endpoint instead of the removed trial endpoint, and the ASP.NET Core options are regrouped into Top-level/Cache/Worker/Console tables. The package Title and Description are tightened (the retired 14-day-trial line is removed). Build hardening: EnableSourceControlManagerQueries=false + IncludeRepositoryUrlInNuspec=false so the private source repository's commit SHA cannot be re-injected into the package's repository metadata. No middleware or worker code change versus 2.0.20.
2.0.19: Documentation alignment with the always-functional licensing model — the README now states that optimization runs out of the box, unlicensed responses carry X-PageSpeed-Warn: unlicensed, and a commercial license is required for production use. The 14-day trial is retired; subscriptions are billed immediately. Docs-only; no middleware or worker code change versus 2.0.18.
2.0.18: Product enhancements and changes around license handling. See the release notes at https://modpagespeed.com/.
2.0.17: Various bug fixes and enhancements. No public API change versus 2.0.16.
2.0.16: README clarity — the on-NuGet docs now state up front that the middleware is a no-op until you activate a trial or license (requests pass through unchanged), removing the apparent contradiction with the "optimization on out of the box" wording. Docs-only; no middleware or worker code change versus 2.0.15.
2.0.14: trial-experience fix. Worker.SocketPath now defaults to an auto-resolved per-process socket when Worker.AutoStart is true (its default), so AddPageSpeed() + UsePageSpeed() optimizes out of the box — previously the default was null, which silently disabled worker coordination and left notifications.received, variants.written, and every Dashboard/Savings/Metrics counter at zero. Set SocketPath to null/empty to deliberately disable coordination (now logs a startup warning); set a concrete path for an out-of-process worker. Reference samples no longer ship the "demo mode" SocketPath=null. Docs/README/FAQ clarify that 2.0 does not rewrite URLs — optimized image variants are served at the original URL via content negotiation (Vary: Accept). No breaking API change.
2.0.13: the embedded /console/ now reaches all of its data pages in the in-process middleware sample — Dashboard, Configuration, URLs, Savings, and Metrics proxy /v1/cache, /v1/stats, /v1/capture, and /v1/config through to the worker (previously only License and Health were wired, so those pages 404'd outside the Docker demo). The worker now reports its real version on /v1/health, generated from VERSION.txt at build time (it had been pinned at 2.0.7 since that release). Release-pipeline reliability fixes; no public API change.
2.0.7: NuGet page + build-metadata polish — README now points readers at https://modpagespeed.com/pricing/ (three visible CTAs in lead, trial step, and Links). CI builds set Deterministic + ContinuousIntegrationBuild, so nuget.info's deterministic + compiler-flags health checks go green and shipped PDBs no longer embed local source paths. No middleware/worker code change vs 2.0.6.
2.0.6: republish 2.0.5 with worker version string corrected — kPageSpeedVersion was stale at 2.0.4 in 2.0.5, so /v1/health and heartbeat telemetry mis-reported the install version on every install. Pinned via a new VersionInvariantTests case that checks version.h, Directory.Build.props, and VERSION.txt agree on every PR.
2.0.5: hotfix — trial + paid activation now work on a stock install. The middleware was not wiring the upstream license-service URL into the worker; new WorkerOptions.LicenseRenewalUrl (default https://api.modpagespeed.com/) closes that gap. License-service allow-list updated in lockstep to accept the NuGet middleware's server=aspnetcore identifier (was silently 400'd by the prod license service since #377).
2.0.4: workbench /console/ now served by the middleware out of the box — trial activation no longer requires Worker.ApiPort. NOTICE + THIRD-PARTY-NOTICES are now packed.
2.0.3: hotfix linux-x64 GLIBC_2.38 baseline; 2.0.2 unlisted.
2.0.2: Linux native binaries statically link libc++/libc++abi/libunwind — dotnet add + dotnet run works end-to-end.
2.0.1: single-package install (NativeAssets pulled transitively).
2.0.0: General Availability. Microsoft Trusted Signing + nuget.org Trusted Publishing.