You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/hosting/infrastructure/reverse-http-cache.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ It contains the Shopware default VCL (Varnish Configuration Language). The conta
37
37
38
38
:::warning
39
39
From version v6.6.x onwards, this method is deprecated and will be removed in v6.7.0.
40
-
Utilising Varnish with Redis involves LUA scripts to determine URLs for the BAN request.
40
+
Using Varnish with Redis involves LUA scripts to determine URLs for the BAN request.
41
41
This can cause problems depending on the setup or network.
42
42
Furthermore, Redis clusters are not supported.
43
43
Therefore, it is advisable to opt for the [Varnish with `XKey`](#configure-varnish) integration instead.
@@ -76,17 +76,17 @@ Make sure to create a Symfony configuration to make it configurable again, as sh
76
76
:::
77
77
78
78
For the most part, using Symfony and Varnish doesn't cause any problem.
79
-
But, when a request passes through a proxy, certain request information is sent using either the *standard Forwarded* header or *X-Forwarded* headers.
79
+
But when a request passes through a proxy, certain request information is sent using either the *standard Forwarded* header or *X-Forwarded* headers.
80
80
For example, instead of reading the `REMOTE_ADDR` header (which will now be the IP address of your reverse proxy), the user's true IP will be stored in a standard Forwarded: for="..." header or an *X-Forwarded-For* header.
81
81
82
82
If you don't configure Symfony to look for these headers, you will get incorrect information about the client's IP address.
83
83
Whether or not the client connects via HTTPS, the client's port and the hostname are requested.
84
84
85
-
Go through [Proxies](https://symfony.com/doc/current/deployment/proxies.html) section for more information.
85
+
Go through [the Proxies](https://symfony.com/doc/current/deployment/proxies.html) section for more information.
86
86
87
87
### Varnish Docker Image
88
88
89
-
Shopware offers a Varnish Docker image that is pre-configured to work with Shopware.
89
+
Shopware offers a Varnish Docker image pre-configured to work with Shopware.
90
90
Find the [image](https://github.com/shopware/varnish-shopware) here.
91
91
The image is based on the official Varnish image and contains the Shopware default VCL with few configurations as environment variables.
92
92
@@ -96,7 +96,7 @@ Varnish `XKey` is a cache key module that allows you to use Varnish with surroga
96
96
It is a module not included in the default Varnish installation.
97
97
It is available for Varnish 6.0 or higher.
98
98
99
-
Checkout the official Varnish installation guide [here](https://github.com/varnish/varnish-modules#installation).
99
+
Check out the official Varnish installation guide [here](https://github.com/varnish/varnish-modules#installation).
100
100
101
101
And also needs to be enabled in the `config/packages/shopware.yml` file:
102
102
@@ -120,7 +120,7 @@ Make sure to replace the `__XXX__` placeholders with your actual values.
120
120
The default configuration Varnish uses hard purges, so when you update a product, the page will be removed from the cache and the next request takes longer because the cache is empty.
121
121
To avoid this, you can use soft purges.
122
122
Soft purge keeps the old page in case and serves it still to the clients and refreshes the cache in the background.
123
-
This way the client gets **always** a cached page and the cache is updated in the background.
123
+
This way the client gets **always** a cached page, and the cache is updated in the background.
124
124
125
125
To enable soft purge, you need to change the varnish configuration.
126
126
@@ -177,17 +177,17 @@ shopware:
177
177
This feature has been introduced with Shopware version 6.4.15.0
178
178
:::
179
179
180
-
By default, the cache will be immediately purged and the next requesting user will get a slow response as the cache has been deleted.
180
+
By default, the cache will be immediately purged, and the next requesting user will get a slow response as the cache has been deleted.
181
181
On soft purge, the user still gets the cached response after the purge, but in the configured time interval, the cache will be refreshed.
182
182
This makes sure that the client gets the fastest response possible.
183
183
184
184
```yaml
185
185
# Be aware that the configuration key changed from `storefront.reverse_proxy` to `shopware.http_cache.reverse_proxy` starting with Shopware 6.6
186
186
shopware:
187
187
http_cache:
188
-
# Allow to serve the out-dated cache for 300 seconds
188
+
# Allow to serve the outdated cache for 300 seconds
189
189
stale_while_revalidate: 300
190
-
# Allow to serve the out-dated cache for an hour if the origin server is offline
190
+
# Allow to serve the outdated cache for an hour if the origin server is offline
191
191
stale_if_error: 3600
192
192
reverse_proxy:
193
193
enabled: true
@@ -214,9 +214,9 @@ So, when a product is invalidated, the object cache and the HTTP cache will also
214
214
There are a few different cache clearing commands:
215
215
216
216
1. `bin/console cache:clear` - Clears and warms up the application cache (In versions before 6.7 this command also cleared the HTTP cache)
217
-
2. `bin/console cache:clear:all` - Clears everything, including application cache, cache poolsand the HTTP cache (Since version 6.6.8)
217
+
2. `bin/console cache:clear:all` - Clears everything, including application cache, cache pools, HTTP cache, and other kernel cache directories (Since version 6.6.8)
218
218
3. `bin/console cache:clear:http` - Clears the reverse proxy cache if enabled, if not it clears the `http` cache pool (Since version 6.6.10)
219
-
4. `bin/console cache:pool:clear --all` - Clears only the object cache (Useful for when you don't want to clear the http cache, preversion 6.6.10)
219
+
4. `bin/console cache:pool:clear --all` - Clears only the object cache (Useful for when you don't want to clear the http cache, pre-version 6.6.10)
220
220
221
221
If you only want to clear the http cache, use `bin/console cache:clear:http`
Copy file name to clipboardExpand all lines: guides/hosting/installation-updates/deployments/build-w-o-db.md
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1375,4 +1375,16 @@ index.json
1375
1375
1376
1376
### Partially compiling the Storefront
1377
1377
1378
-
You can also build just the Javascript bundle using `CI=1 SHOPWARE_SKIP_THEME_COMPILE=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true bin/build-storefront.sh` (without the need for the above loader) in your CI. After that, run `bin/console theme:dump` on your production system when the database is available. This will happen automatically if theme variables are changed via the admin panel.
1378
+
You can also build just the JavaScript bundle using `CI=1 SHOPWARE_SKIP_THEME_COMPILE=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true bin/build-storefront.sh` (without the need for the above loader) in your CI. After that, run `bin/console theme:dump` on your production system when the database is available. This will happen automatically if theme variables are changed via the admin panel.
1379
+
1380
+
## Cache directory and hash implications
1381
+
1382
+
When using `bin/ci` or `ComposerPluginLoader`, the cache directory name includes a hash computed from active plugins. Since `ComposerPluginLoader` marks all Composer-installed plugins as active, while `DbalKernelPluginLoader` (used by web requests) respects the database `active` column, the cache hashes can differ.
1383
+
1384
+
This means:
1385
+
1386
+
- Cache warmed with `bin/ci` uses a hash based on all Composer-installed plugins being active
1387
+
- Production web requests use a hash based on the actual database plugin state
1388
+
- If any plugin is deactivated in the database, web requests create a new cache directory
1389
+
1390
+
To ensure cache is properly cleared across all configurations, use `cache:clear:all` instead of `cache:clear` in deployment scripts.
Additionally, the `shopware-app-signature` header will be provided, which contains a cryptographic signature of the query string.
164
+
Additionally, the `shopware-app-signature` header will be provided, which contains a cryptographic signature of the query string.
165
165
The secret used to generate this signature is the `app secret`, which is unique per app and will be provided by the Shopware Account if you upload your app to the store.
166
166
This secret won't leave the Shopware Account, so it won't even be leaked to the shops installing your app.
167
167
@@ -317,7 +317,7 @@ Starting from Shopware version 6.4.1.0, the current Shopware version will be sen
317
317
Starting from Shopware version 6.4.5.0, the current language id of the Shopware context will be sent as a `sw-context-language` header, and the locale of the user or locale of the context language is available under the `sw-user-language` header.
318
318
:::
319
319
320
-
The request is signed with the `shop-secret` that your app provided in the [registration response](app-base-guide#registration-response) and the signature can be found in the `shopware-shop-signature` header.
320
+
The request is signed with the `shop-secret` that your app provided in the [registration response](app-base-guide#registration-response) and the signature can be found in the `shopware-shop-signature` header.
321
321
You need to recalculate that signature and check that it matches the provided one to make sure that the request is really sent from the shop with that shopId.
322
322
323
323
You can use the following code snippet to generate the signature:
Copy file name to clipboardExpand all lines: guides/plugins/plugins/framework/caching/index.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -409,6 +409,20 @@ sw-force-cache-invalidate: 1
409
409
## Manual cache clear
410
410
411
411
You can also manually clear the caches when you performed some actions that made a cache invalidation necessary, but where it was not triggered automatically.
412
-
To clear all caches, you can execute the `cache:clear:all` command, which clears the HTTP-Cache, the object caches as well as any other caches that are registered in the system.
412
+
413
+
To clear all caches, you can execute the `cache:clear:all` command, which clears the HTTP-Cache and the object caches, and removes other kernel cache directories.
414
+
413
415
The `cache:clear` command on the other hand will only clear the object caches, but won't invalidate the HTTP-Cache.
414
416
On the other hand, the `cache:clear:http` command will clear the complete HTTP-Cache, but won't invalidate the object caches.
417
+
418
+
::: warning
419
+
`cache:clear`only clears the cache directory matching the current kernel's configuration. If you run `bin/console cache:clear` but web requests still use stale cache, the CLI and web server may be using different cache directories. This can happen when plugins are in different states (e.g., installed via Composer but not yet activated in the database). Use `cache:clear:all` to clear all cache variants.
420
+
:::
421
+
422
+
::: details How cache:clear works internally
423
+
The Symfony `cache:clear` command uses an atomic directory swap to ensure the application always has a valid cache. It first removes any leftover temporary directories, then creates and warms up the new cache in `var/cache/{env}_new/`. Once ready, it renames the current cache directory to a backup and moves the new one into place. Finally, it removes the backup.
424
+
425
+
This approach ensures zero downtime because the application always has a working cache directory. The swap uses filesystem rename operations which are atomic on most systems. On NFS filesystems, directories are deleted instead of renamed due to limitations with atomic operations.
426
+
427
+
For more details, see the [Symfony CacheClearCommand source](https://github.com/symfony/symfony/blob/7.4/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php).
0 commit comments