New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard Cache Exclusion #1392

Closed
peterbaker opened this Issue Apr 18, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@peterbaker

peterbaker commented Apr 18, 2017

Expected behaviour

This was brought up to the devs way back in August/September 2016 on Statamic 2, and a fix was provided, but never implemented in the core, so we have to hack AbstractCacher.php every time we update Statamic, even now in Statamic 2.5.8.

Basically, the syntax for static_caching_exclude does not allow for wildcard urls, so we can't avoid caching paginated sections of our blog (like taxonomy indexes).

This should work:
`static_caching_exclude:

  • /blog
  • '/blog/category/*'
  • '/blog/tags/*'`

...but it doesn't. It actually breaks all caching exclusions.

The core hack that fixes it

The hack we were provided is thus, basically commenting out a chunk seemingly important stuff:

AbstractCacher.php (line 93-104)

protected function getUrl(Request $request)
    {
        $url = $request->path();

        // if (! Config::get('static_caching_ignore_query_strings')) {
        //     if ($query = http_build_query($request->query->all())) {
        //         $url .= '?' . $query;
        //     }
        // }

        return Str::ensureLeft($url, '/');
    }

Can we get wildcard cache exclusions supported officially?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment