cms icon indicating copy to clipboard operation
cms copied to clipboard

404 errors are cached with »half« static caching

Open florianbrinkmann opened this issue 1 year ago • 5 comments

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 half static caching
  • Create and publish two pages, one with the slug parent and one with the slug child, both on the top level of the page tree.
  • View the URL /parent/child at the frontend, you get a 404 error
  • Move the child page in the page tree below the parent page and save the page tree
  • Visit /parent/child again 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.

florianbrinkmann avatar Sep 04 '24 09:09 florianbrinkmann

Do you have the share_errors config option enabled in the config/statamic/static_caching.php config file?

duncanmcclean avatar Sep 04 '24 10:09 duncanmcclean

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(?)

florianbrinkmann avatar Sep 04 '24 10:09 florianbrinkmann

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.

duncanmcclean avatar Sep 04 '24 11:09 duncanmcclean

Yes, 404s are cached intentionally when using half measure.

jasonvarga avatar Sep 04 '24 14:09 jasonvarga

And what about the described case that the collection tree changes so a cached 404 URL becomes a valid content URL?

florianbrinkmann avatar Sep 04 '24 14:09 florianbrinkmann