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?

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('')
                        && !Str::startsWith($path, 'api', true)
                        && !Str::startsWith($path, 'panel', true)
                        && !Str::contains($query, 'token=', true);
        if ($shouldCache) {
            ->header('Cache-Control', 'max-age=1800, must-revalidate') // 30 minutes (60 * 30)
        else {
            ->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.