statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
31 stars 1 forks source link

Static cache config inclusion instead of exclusion #896

Closed rrelmy closed 1 year ago

rrelmy commented 1 year ago

In some projects it would be helpfull to have a inclusion list instead of an exclusion list.

In v3.3 this can be achieved with a custom UrlExcluder class which does some inverted logic., but it would be nice to be able to have such control in the core.

Some ideas we had:

The excluder could support negating But therefor all rules need to be checked instead of stopping after the first.

'urls' => [
  '*',
  '!/cache-me-page',
]

Have a separate inclusion list That's what we did with a custom class, the structure or naming would need to be improved of course

    'exclude' => [
        'class' => App\Helpers\CustomUrlExcluder::class,
        'urls' => [
            '*',
        ],
        'include' => [
            '/cache-me-page',
        ]
    ],
jasonvarga commented 1 year ago

Sounds like you successfully built the feature you're after using a custom excluder class. Nice!

I don't think this needs to be in the core. You could also consider wrapping the entirety of your single page in a {{ cache }} tag as an alternative to static caching.