SilverStripe\StaticPublishQueue\Job\StaticCacheFullBuildJob
Class StaticCacheFullBuildJob
Adds all live pages to the queue for caching. Best implemented on a cron via StaticCacheFullBuildTask.
WARNING: this job assumes that there are not too many pages to process (dozens are fine, thousands are not)
as collecting URLs from all live pages will either eat up all available memory and / or stall
If your site has thousands of pages you need to consider a different static cache refresh solution
Ideally, the whole site re-cache would be segmented into smaller chunks and spread across different times of the day
Synopsis
class StaticCacheFullBuildJob
extends Job
{
- // methods
- public string getTitle()
- public string getSignature()
- public void setup()
- public void process()
- protected array getAllLivePageURLs()
- protected void processUrl()
- protected void updateCompletedState()
- // Inherited methods from Job
- public int|null getRunAsMemberID()
- public void setup()
- public void getSignature()
- public void process()
- protected abstract void processUrl()
- protected void markUrlAsProcessed()
- protected void updateCompletedState()
- protected int getChunkSize()
- protected void handleFailedUrl()
Hierarchy
Tasks
Line | Task |
---|---|
135 | look here when integrating subsites |
Methods
protected
public
- getSignature()
- getTitle()
- process() — Do some processing yourself!
- setup()
Inherited from SilverStripe\StaticPublishQueue\Job
protected
- getChunkSize()
- handleFailedUrl() — This function can be overridden to handle the case of failure of specific URL processing such case is not handled by default which results in all such errors being effectively silenced
- markUrlAsProcessed() — Move URL to list of processed URLs and update job step to indicate progress indication of progress is important for jobs which take long time to process jobs that do not indicate progress may be identified as stalled by the queue and may end up paused
- processUrl() — Implement this method to process URL
- updateCompletedState() — Check if job is complete and update the job state if needed
public
- getRunAsMemberID() — Static cache manipulation jobs need to run without a user this is because we don't want any session related data to become part of URLs For example stage GET param is injected into URLs when user is logged in This is problematic as stage param must not be present in statically published URLs as they always refer to live content Including stage param in visiting URL is meant to bypass static cache and redirect to admin login this is something we definitely don't want for statically cached pages
- getSignature()
- process()
- setup()