2

I've turned on "Full Page Caching" to "On - In all cases" under "Cache & Speed Settings" and tested it by clearing cache and loading my home page in a separate browser. But it seems the load time seems to remain the same no matter how many times I refreshed the browser, leading me to believe that the CMS is still going to the DB to retrieve the page, instead of from the cache.

I managed to track the codes down to specifically this bit inside /concrete/src/Cache/Page/PageCache.php

/**
* Note: can't use the User object directly because it might query the database.
* Also can't use the Session wrapper because it starts session which triggers
* before package autoloaders and so certain access entities stored in session
* will break.
*/
public function shouldCheckCache(Request $req) {
    $session = \Config::get('concrete.session.name');
    $r = \Cookie::get($session);
    if ($r) {
        return false;
    }
    return true;
}

If I force this function to always return true, I will find that subsequent reloads of the browser see a much shorter load time, which I believe shows that the page is retrieved from the cache.

The function seems to check if the "CONCRETE5" cookie has been set. If so, then the cache will be ignored. I don't really understand what this all means, so hope someone can help shed some light on whether I'm doing something wrong, or what I should do instead.

Thank you for any help!

Ron Lim
  • 129
  • 1
  • 7
  • You should head over to github and ask there - think there will be a much better chance of getting a good answer on this question there: https://github.com/concrete5/concrete5 – Nicolai Krüger Nov 29 '15 at 09:48
  • Stackoverflow should be a find place for these kinds of question @NicolaiDitlevKroghKrüger – Korvin Szanto Dec 27 '15 at 19:47
  • @KorvinSzanto yes, it should. But there is very little activity on C5 on Stackoverflow - i.e. it took a month for this to be answered. – Nicolai Krüger Dec 28 '15 at 08:43
  • @NicolaiDitlevKroghKrüger the type of support you're likely to get on the forums is more geared to site users / site owners and not so much for developers. This question would likely get more eyes on the forums but almost certainly would not get a thorough answer. We're trying to encourage the use of SO for these kinds of deeper developer questions. – Korvin Szanto Dec 28 '15 at 20:43
  • @KorvinSzanto I'm not encouraging all kinds of developer question to get asked on the forum or github - rather this specific question since there is not much activity here AND it seems more like a suggestion/discussion about C5 cache. My initial comment might be seen as encouraging all C5 issues to be kept from SO - that was not the meaning of it. – Nicolai Krüger Dec 29 '15 at 08:34
  • Fair, I just wanted to be clear that even if it takes longer (which hopefully it won't in the future with more community coming to stackoverflow) you're likely to get a much better more thorough answer here than in the forums. – Korvin Szanto Dec 29 '15 at 20:35

1 Answers1

1

The initial reason why this existed is to disable cache completely if the user is logged in, likely there's a better way to do this today so we can benefit from discussion in github on this.

The peculiarity you're seeing is an edge case where all of these are true

  • You are not logged in
  • You have a session cookie
  • Cache is built and enabled

This generally doesn't happen for real site users since rendering the site from cache prevents the session from starting. The way to really test this is to open a new incognito tab after the cache has already been built and navigate around your site. From what I can tell, if the cache is invalidated and any one page loads not from cache, every subsequent request goes around cache.

Nicolai is correct in that we can likely benefit from making this a little smarter and more robust, probably a good thing to open a new discussion issue for on github.

EDIT: I opened this github issue for the discussion

Korvin Szanto
  • 4,531
  • 4
  • 19
  • 49