Addpixel / KirbyComments

[Kirby 2] File-based comments stored as subpages for the Kirby CMS.
MIT License
68 stars 5 forks source link

Kill page cache on preview/submit #13

Closed gerritvanaaken closed 7 years ago

gerritvanaaken commented 7 years ago

If you have kirby file cache activated, you will never see the comment preview, and so you can never send any comment :-( Maybe there is a kirby api for explicitely deleting the cache for the page you are commenting on.

florianpircher commented 7 years ago

There is: $page->reset(). The only problem with this method is, that it never will be called, because the page is loaded from the cache and so the method is not getting called. I try to look for an alternative …

florianpircher commented 7 years ago

And adding the current page temporarily to cache.ignore does not work, because pages are cached before the code of plugin is executed.

florianpircher commented 7 years ago

It seems like this problem can currently not be fixed. Comments are dynamic content and don’t go together with Kirby’s caching strategy.

gerritvanaaken commented 7 years ago

Maybe the Kirby team has to change the caching bevahiour. If a page is called with a post request and post data incoming, the cache will not be used.

florianpircher commented 7 years ago

I found a black-magic method of ignoring the cache when previewing or posting a comment. Now I have discovered, that you would also have to ignore the page when rendering the form, regardless of whether or not a comment was posted. The form contains a hidden input field with a random key for extra security (e.g. to prevent cross-site request forgery). This means, that you would have to ignore your articles at all times from the cache.

This can be achieved using a wildcard ignore pattern:

c::set('cache.ignore', array(
  'weblog/*'
));