Skip to content

Commit

Permalink
Forcibly generate the cache if not be cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Oct 24, 2023
1 parent eb47a0c commit 7ef3507
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changed

- Changed the refreshable status check to always conside elements with `live` and `active` statuses as refreshable ([#572](https://github.com/putyourlightson/craft-blitz/issues/572)).
- Refreshing expired cached now forcibly generates new cached pages if they are not cleared ([#573](https://github.com/putyourlightson/craft-blitz/issues/573)).

### Fixed

Expand Down
8 changes: 4 additions & 4 deletions src/models/SettingsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ public function clearOnRefresh(bool $force = false): bool
return true;
}

return $this->refreshMode == self::REFRESH_MODE_CLEAR
|| $this->refreshMode == self::REFRESH_MODE_CLEAR_AND_GENERATE;
return $this->refreshMode === self::REFRESH_MODE_CLEAR
|| $this->refreshMode === self::REFRESH_MODE_CLEAR_AND_GENERATE;
}

/**
Expand All @@ -479,8 +479,8 @@ public function generateOnRefresh(bool $force = false): bool
return false;
}

return $this->refreshMode == self::REFRESH_MODE_EXPIRE_AND_GENERATE
|| $this->refreshMode == self::REFRESH_MODE_CLEAR_AND_GENERATE;
return $this->refreshMode === self::REFRESH_MODE_EXPIRE_AND_GENERATE
|| $this->refreshMode === self::REFRESH_MODE_CLEAR_AND_GENERATE;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/services/RefreshCacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,10 @@ public function refreshSiteUriIfExpired(SiteUriModel $siteUri): void

$this->addCacheIds($cacheIds);

// Force clear the cache if it will not be regenerated.
$forceClear = !Blitz::$plugin->settings->generateOnRefresh();
// Forcibly generate the cache if it will not be cleared.
$forceGenerate = !Blitz::$plugin->settings->clearOnRefresh();

$this->refresh($forceClear);
$this->refresh(false, $forceGenerate);
}

/**
Expand Down Expand Up @@ -530,10 +530,10 @@ public function refreshExpiredCache(): void
}
}

// Force clear the cache if it will not be regenerated.
$forceClear = !Blitz::$plugin->settings->generateOnRefresh();
// Forcibly generate the cache if it will not be cleared.
$forceGenerate = !Blitz::$plugin->settings->clearOnRefresh();

$this->refresh($forceClear);
$this->refresh(false, $forceGenerate);
}

/**
Expand Down

0 comments on commit 7ef3507

Please sign in to comment.