selveq / persisted-query
Magento 2 Persisted Query extension for ScandiPWA theme
Package info
github.com/sellveq/persisted-query
Type:magento2-module
pkg:composer/selveq/persisted-query
Requires
- php: ^8.3
- colinmollenhour/credis: ^1.10
- magento/framework: ^103.0
- magento/module-backend: ^102.0
- magento/module-cache-invalidate: ^100.4
- magento/module-catalog: ^104.0
- magento/module-config: ^101.2
- magento/module-graph-ql: ^100.4
- magento/module-graph-ql-cache: ^100.4
- magento/module-page-cache: ^100.4
- magento/module-store: ^101.1
Requires (Dev)
None
Suggests
- ext-redis: Faster serialization of the registered queries through phpredis
Provides
None
Conflicts
None
Replaces
This package is not auto-updated.
Last update: 2026-09-19 19:52:31 UTC
README
Fork of scandipwa/persisted-query 3.1.1, maintained by Selveq for Magento 2.4.9 and PHP 8.3. Module name and namespace are unchanged, and the package replaces scandipwa/persisted-query at every version, so it installs as a drop-in replacement. Selveq is not affiliated with or endorsed by Scandiweb.
What it does
- Executes a registered query on
GET /graphql?hash=<hash>and answers withX-Pooland aCache-Controlmax-age, so Varnish or a CDN can cache the response; an unknown hash answers410. - Registers a query on
PUT /graphql?hash=<hash>only under the hash the theme computes for it (MurmurHash3 seed 1 over the query text as UTF-16 code units); a mismatch answers400. - Caps the
SW-cache-agea client may ask for at a configurable ceiling, honours0as do-not-cache, and answers uncacheable queries withno-store. - Keeps registrations in Redis for 30 days;
bin/magento scandipwa:pq:flushand thepersisted_query_responsecache type purge the Varnish pool.
Install
composer require selveq/persisted-query bin/magento setup:upgrade bin/magento setup:config:set --pq-host=redis --pq-port=6379 --pq-database=5 --pq-scheme=tcp
Redis holds the registered queries, and caching the responses needs Varnish as the caching application. After upgrading from scandipwa/persisted-query, run bin/magento scandipwa:pq:flush once.
Configuration
| Setting | Default | What it does |
|---|---|---|
scandipwa_persisted_query/cache/default_ttl |
60 |
max-age when the registration carried no SW-cache-age |
scandipwa_persisted_query/cache/max_ttl |
2592000 |
ceiling for SW-cache-age, never above the 30-day registration lifetime |
scandipwa_persisted_query/registration/verify_hash |
1 |
refuse a registration whose hash is not the theme's hash of the query |
License
OSL-3.0, the license of the original work. Scandiweb's copyright notices are kept in every file, and each file Selveq changed carries a Modifications © Selveq notice.