Panel shows cached version of page after changing content

Iā€™m running the latest version of Kirby, 3.0.3. Whenever I save anything in the panel, it falls back to a cached version of the page while the content file gets edited correctly. Iā€™ve tried to reĆÆnstall kirby and remove all plugins temporarily without result.

The only way to work in the panel currently is by having inspector opened with ā€˜disable cacheā€™ enabled.

What could be the cause of this?

Maybe related to this?
https://getkirby.com/docs/guide/troubleshooting/panel#opcache

Gave it a try, but doesnā€™t work.

I have similar problem after setting browser cache in my .htaccess file (I followed this guide).

Iā€™m using similar htaccess caching settings. The issue persists though after commenting the settings.

I have to say that I canā€™t think of more pointers - seems like it is really connected to your server setup.

Iā€™m running into this myself now. Content is only updated when dev tools is open and caching disabled.

Any chance your server is emitting Cache-Control headers? Or, if youā€™re behind a CDN that automatically caches pages, are you making sure api/panel requests are not being cached?

For example, I emit Cache-Control headers like this so Cloudflare knows what to cache and what to not.

'hooks' => [
    'route:before' => function ($route, $path, $method) {
        $kirby = kirby();
        $query = Url::query() ?: '';
        
        $response = $kirby->response();
        
        $shouldCache =  'GET' === $method
                        && $kirby->option('cache.pages.active')
                        && !Str::startsWith($path, 'api', true)
                        && !Str::startsWith($path, 'panel', true)
                        && !Str::contains($query, 'token=', true);
        
        if ($shouldCache) {
            $response
            ->header('Cache-Control', 'max-age=1800, must-revalidate') // 30 minutes (60 * 30)
            ;
        }
        else {
            $response
            ->header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
            ->header('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT')
            ;
        }
    }
],

But if youā€™re setting headers in your Apache/Nginx config, then youā€™ll probably want to make adjustments there.

@neildaniels Ah, thanks, that reminded me that I had actually set Expires HTTP headers in my .htaccess recently for testing and completely forgotten about it :see_no_evil:. All good now.

Updated troubleshooting guide.