Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Allowing users to refresh the cache[SUSSED]


Go to End


2 Posts   952 Views

Avatar
simples

Community Member, 77 Posts

20 July 2013 at 4:31am

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.

Avatar
simples

Community Member, 77 Posts

20 July 2013 at 7:46am

Edited: 20/07/2013 7:48am

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.