CDN Full Page Caching with C5

To take advantage of a CDN’s ability to cache HTML on edge servers, we sometimes like to enable HTML caching on certain high traffic pages on a site. We haven’t figured out a way to do it with C5 because of the admin toolbar: if the CDN caches the HTML with admin toolbar present that would be bad :wink:

For WordPress, you can easily disable the admin bar which makes it possible to cache HTML content. Does anyone know how we might be able to achieve the same?

One idea is to somehow append a querystring to pages when I need them to show the toolbar, but I would need to know first if its possible to disable the toolbar somehow.

1 Like

You can bypass CDN for sign-in users only.
C5 sets CONCRETE5_LOGIN cookie value only when you sign in, and most CDN services support caching based on cookie values.

Ahh, darn! That would be great, unfortunately we use CloudFlare and they don’t offer this, I don’t think StackPath does either.

Another way to get around this is to use a different domain for editing the website.

Here are a few ideas:

1 Like

That second link might be the winning ticket for us actually! I didn’t think we could go with a separate domain/subdomain because we always plug in the Canonical URL in, but I suppose with this code (if REDIRECT_TO_BASE_URL is still a constant in the new versions) and a secondary URL perhaps, this may work:

<?php
if (strpos($_SERVER['HTTP_HOST'],'direct') !== FALSE) {
define('REDIRECT_TO_BASE_URL', false); }
?>