404 errors are cached with »half« static caching
Bug description
I noticed that 404 pages are cached when half static caching is active. That’s not the case with full static caching.
How to reproduce
- Activate
halfstatic caching - Create and publish two pages, one with the slug
parentand one with the slugchild, both on the top level of the page tree. - View the URL
/parent/childat the frontend, you get a 404 error - Move the
childpage in the page tree below theparentpage and save the page tree - Visit
/parent/childagain and you still get the 404
Logs
No response
Environment
Environment
Application Name: Statamic
Laravel Version: 11.21.0
PHP Version: 8.3.9
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: example.com
Maintenance Mode: OFF
Timezone: UTC
Locale: de
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: null
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file
Statamic
Addons: 0
Sites: 1
Stache Watcher: Enabled
Static Caching: half
Version: 5.17.0 PRO
Installation
Other (please explain)
Additional details
We use a custom starter kit at work, where I tested it, but it’s pretty basic without much modifications.
Do you have the share_errors config option enabled in the config/statamic/static_caching.php config file?
Oh, didn’t knew about that option. But it’s not included in the static_caching.php in that project, so I guess it shouldn’t be enabled(?)
It's a new config option, so I just wondered if you had it enabled.
It looks like 404 are now cached when using half-measure caching. If you add that config option, it'll mean there's only 1 cached 404 page.
See https://github.com/statamic/cms/pull/10294 for more details.
Yes, 404s are cached intentionally when using half measure.
And what about the described case that the collection tree changes so a cached 404 URL becomes a valid content URL?