cms icon indicating copy to clipboard operation
cms copied to clipboard

404 error on item view after first save - using static cache (half strategy)

Open jamie-b5 opened this issue 1 year ago • 6 comments

Bug description

We are using static caching. Half strategy.

When we add an item to a collection and hit save the front end item url throws a 404. It does this until we save the item a second time, at which point the url resolves to the correct record.

How to reproduce

  1. Enable static caching (half strategy)
  2. Create a new record in a collection
  3. Visit the url of the item (front end) - this shows a 404
  4. Save the record a second time
  5. Visit the url of the item - now works

Logs

No response

Environment

Environment
Application Name: Dave Whyte Animation
Laravel Version: 9.52.16
PHP Version: 8.1.21
Composer Version: 2.4.2
Environment: production
Debug Mode: OFF
URL: davewhyteanimation.com
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 0
Antlers: runtime
Sites: 1
Stache Watcher: Disabled
Static Caching: half
Version: 4.52.0 PRO

Installation

Other (please explain)

Antlers Parser

None

Additional details

Statamic install - cloned from a slightly earlier repo then updated.

jamie-b5 avatar Mar 05 '24 12:03 jamie-b5

A client has also reported the same issue to us regarding their site also using half strategy caching.

chopperoon avatar Mar 05 '24 12:03 chopperoon

Bumping as I'm also experiencing the same issue on multiple sites. It seems to happen regardless of the caching strategy and save method. Either clicking the 'Save & Publish' button or hitting Cmd+S will result in a 404 unless saved a second time.

I'm able to replicate this issue consistently on sites running 4.45.0 up to 4.57.3.

Update: Setting the 'Max Depth' field to anything other than blank causes the issue, irrespective of eloquent or flat file. Keeping that field blank solves the problem

CjRootStudio avatar May 13 '24 13:05 CjRootStudio

@jamie-b5 @CjRootStudio I have similar issue. Does the 404 error disappear when you save the entry and then warm or refresh the Stache instead of saving the entry a second time?

morhi avatar May 21 '24 15:05 morhi

This seemed to be resolved for us by upgrading the core Statamic version FYI.

jamie-b5 avatar May 22 '24 08:05 jamie-b5

Thanks Jamie - did you upgrade to version 5 or is there a version 4 release that fixed it for you?

CjRootStudio avatar May 22 '24 08:05 CjRootStudio

I think https://github.com/statamic/cms/pull/10135 fixed it. Can you confirm that? It was released yesterday.

morhi avatar May 22 '24 08:05 morhi