jonassiewertsen / statamic-livewire

A Laravel Livewire integration for Statamics antlers engine
83 stars 14 forks source link

Fix static caching #64

Closed aerni closed 2 months ago

aerni commented 2 months ago

This PR makes the AssetsReplacer work with full measure static caching and closes #63.

Previously, we injected the Livewire assets in the replaceInCachedResponse() method. However, this method is never hit when using full measure static caching. I didn't initially catch this issue locally, as mentioned in #63.

All assets are now injected in the cached response to make it work with both half and full measure static caching. I basically copied Livewire's assets injection to make this work.

The 419 Page Expired issue mentioned in #63 was due to the CSRF token not being injected at the time of making a request to this.$wire. This is a separate issue that requires a PR to Statamic's NoCacheReplacer. See https://github.com/statamic/cms/pull/10306.

aerni commented 2 months ago

This PR might yet need another refactor as per recent discussions in https://github.com/statamic/cms/pull/10306.

aerni commented 2 months ago

Any chance to get this merged soon? There's already been a couple of people on Discord asking why static caching doesn't work anymore with the latest release.

marcorieser commented 2 months ago

@aerni you've set it as draft. Is it ready?

aerni commented 2 months ago

Oh yeah, sorry. Totally missed that. This PR is ready to go.

jonassiewertsen commented 2 months ago

Thanks for your work @aerni