Deleted posts still shown in panel

Hi there. My again.

This time, already deleted files will continue to show up in Panel. Again, MAMP, MacOS. The weirdness does survive a web-server restart, wtfbbq?


I start believing my karma is done for …

panel might be fooled by an cached api response. try on a real webserver and/or a private tab mode in your favourit browser.

Do you have Opcache enabled in Mamp? I’ve never seen this in a Mamp environment till now.

Tried that with bytecode caches on and off.

Ah, here we go!

Seems like my default cache settings are suitable for the public website, but not for the Panel. Will try and see how to mitigate that.

Thank you all!

Is it a good strategy to make all requests against /api non-cachable?

This might make for a nice CR: Have the API send its own cache headers to make sure we‘re good.

Cobbled together a little plugin, making use of the route:before hook.

Kirby::plugin('itst/helpers', [
  'hooks' => [
    'route:before' => function ($route, $path, $method) {
      if (substr($path, 0, 4) === 'api/') {
        header('Cache-Control: private, no-cache');
      } else {
        header('Cache-Control: public');

That’s certainly not ideal. It moves web server functionality away of web server. Yet, for my local setup, that‘s fine.

you could wrap it in an if clause using kirby()->system()->isLocal() to limit it for localhost setups.

1 Like