Jump to:

22977 Posts in 11742 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Allowing users to refresh the cache[SUSSED]

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 241 Views
  • simples
    Avatar
    Community Member
    76 Posts

    Allowing users to refresh the cache[SUSSED] Link to this post

    Hi,

    I am developing a small community site using Version 2.4. In order to make response times snappy I use Static Publisher. Since the site is small I have provided a link in the top menu of the CMS which when clicked refreshes the cache of ALL pages. It does this by running dev/buildcache?flush=1.

    My problem is that we have now allowed users in the community to log in and add their own content. However these users have been given restricted permissions. Unfortunately it seems that only administrators can refresh the cache.

    Is there any way in which these restricted users can be allowed to refresh the cache so that they see content which they add when browsing the site? Ideally I am looking for a simple tweek, perhaps to the codebase, rather than a complete rework.

    Thanks.

  • simples
    Avatar
    Community Member
    76 Posts

    Re: Allowing users to refresh the cache[SUSSED] Link to this post

    Hi,

    I think I have this sussed now.

    At mysite\code\Page.php I changed

    function pagesAffectedByChanges() {
    $urls = $this->subPagesToCache();
    if($p = $this->Parent) $urls = array_merge((array)$urls, (array)$p->subPagesToCache());
    return $urls;
    }

    to

    function pagesAffectedByChanges() {
    $urls = $this->subPagesToCache();
    if($p = $this->Parent) $urls = array_merge((array)$urls, (array)$p->subPagesToCache());
    $urls[]=BASE_URL.'/';
    return $urls;
    }

    Whenever a user, who has not got administrator privileges, clicks the "Save and Publish" button, cache files for all changed pages including the homepage now get refreshed.

    Please note that nothing gets refreshed if the "Save" button is clicked.

    241 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.