Skip to content

Commit

Permalink
exclude url path(s) from being cached, new release
Browse files Browse the repository at this point in the history
  • Loading branch information
Klearchos Douvantzis committed Apr 30, 2019
1 parent 7e84f35 commit 6c9ff58
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.14 - 2019-04-30

### Fixed
- Add urls to exclude

## 1.0.13 - 2019-02-07

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To work in DEV-mode: use the force option in the settings.

## Configuring HTML Cache

If the plugin is enabled it works out of the box and no special cache tags are needed. If DevMode in Craft CMS is enabled, you will have to force enable the plugin by enabling the 'Force On' plugin setting.
If the plugin is enabled it works out of the box and no special cache tags are needed. If DevMode in Craft CMS is enabled, you will have to force enable the plugin by enabling the 'Force On' plugin setting. You can also exclude url path(s) from being cached.


## Using HTML Cache
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bolden/htmlcache",
"description": "Cache pages to HTML and boost website performance on Craft CMS 3.",
"type": "craft-plugin",
"version": "1.0.13",
"version": "1.0.14",
"keywords": [
"craft",
"cms",
Expand Down
18 changes: 10 additions & 8 deletions src/services/HtmlcacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,17 @@ private function isPathExcluded()
$requestedSiteId = \Craft::$app->getSites()->getCurrentSite()->id;

// compare with excluded paths and sites from the settings
foreach ($this->settings->excludedUrlPaths as $exclude) {
$path = reset($exclude);
$siteId = intval(next($exclude));
if (!empty($this->settings->excludedUrlPaths)) {
foreach ($this->settings->excludedUrlPaths as $exclude) {
$path = reset($exclude);
$siteId = intval(next($exclude));

// check if requested path is one of those of the settings
if ($requestedPath == $path || preg_match('@' . $path . '@', $requestedPath)) {
// and if requested site either corresponds to the exclude setting or if it's unimportant at all
if ($requestedSiteId == $siteId || $siteId < 0) {
return true;
// check if requested path is one of those of the settings
if ($requestedPath == $path || preg_match('@' . $path . '@', $requestedPath)) {
// and if requested site either corresponds to the exclude setting or if it's unimportant at all
if ($requestedSiteId == $siteId || $siteId < 0) {
return true;
}
}
}
}
Expand Down

0 comments on commit 6c9ff58

Please sign in to comment.