Skip to main content

filter · Cache control

Local storage cache (local_storage_cache)

Category:
Caching
CoreFilters:
No
OptimizeForBandwidth:
No
Risk:
Dangerous set

Retired from 2.7.0. From 2.7.0, local_storage_cache is accepted and ignored: the name still works in every configuration syntax, in EnableFilters and in query parameters, enabling it logs one warning per process, and nothing changes in the page. Disabling or forbidding it is silent, so a configuration that still lists it keeps loading; remove the line when convenient. A rewritten page carries no local-storage cookie, script or data-pagespeed-lsc-* attribute, and the filter no longer adds a Vary: User-Agent token or a noscript redirect.

How it works

The filter moved the bytes of inlined images and CSS into the browser’s localStorage and tracked them in a _GPSLSC cookie. That cookie grew with every stored resource until a server could start refusing requests with “400 request header too large”, and localStorage has size limits (typically 5-10 MB per origin) and can be cleared by the user at any time. In 2.6.0 and earlier the filter still runs as described here; it is not recommended there either.

For the same repeat-view saving, use extend_cache: it keeps resources at external, content-hashed URLs with a one-year lifetime, with no cookie and no scripts.

When to use it

  • In the dangerous set: no RewriteLevel enables it, not even AllFilters. It exists for testing and measurement, not for production traffic.
  • Risk rating on these docs: Dangerous.
  • Retired in 2.7.0: the name is still accepted but has no effect, and enabling it logs a warning.

Risks

The Cache control page lists no specific risks for this filter. If a page misbehaves with it, DisableFilters local_storage_cache turns it off for the scope you set it in.

Configuration

Enable it in the module configuration, at server, virtual-host or location scope:

Apache

ModPagespeedEnableFilters local_storage_cache

nginx

pagespeed EnableFilters local_storage_cache;

IIS (pagespeed.config)

pagespeed EnableFilters local_storage_cache

Scoping, ForbidFilters and the thresholds filters read: Choosing filters.

Live example

Stores inlined CSS and images in the browser's local storage for repeat visits.

Measured on the demo page, original against optimized:

  • HTTP requests

    3 → 2 −1

See the before and after, with the source diff →

Frequently asked questions

What does the local_storage_cache filter do?
Retired from 2.7.0. From 2.7.0, local_storage_cache is accepted and ignored: the name still works in every configuration syntax, in EnableFilters and in query parameters, enabling it logs one warning per process, and nothing changes in the page. Disabling or forbidding it is silent, so a configuration that still lists it keeps loading; remove the line when convenient. A rewritten page carries no local-storage cookie, script or data-pagespeed-lsc-* attribute, and the filter no longer adds a Vary: User-Agent token or a noscript redirect.
Is local_storage_cache enabled by default?
No. local_storage_cache is in the dangerous set, which no RewriteLevel enables, not even AllFilters. Enable it by name, for testing and measurement only.
How do I enable local_storage_cache on Apache and nginx?
Add ModPagespeedEnableFilters local_storage_cache on Apache or pagespeed EnableFilters local_storage_cache; on nginx. On IIS, add pagespeed EnableFilters local_storage_cache to pagespeed.config.

This page is drawn from the local_storage_cache entry on Cache control. Every filter in one table: PageSpeed filters.

Search