Open croxton opened 6 years ago
Sorry, I'm not trying to ignore this, I'm just really swamped. I imagine the next time I work on this will be when I do another Craft 3 site. I'm not sure when that will be.
Since Craft 3 has multi-site support, it does seem like a good idea for this plugin to have it too.
No worries. I'm not sure I will actually need it yet, but if so I may fork and submit a PR, if that's OK?
You can certainly submit a PR. The worst I can do is reject it. I like to keep things super simple and I wonder if possibly even splitting up the functionality into another add-on might be the ticket. I recently built an add-on for EE that only clears static cache. https://github.com/buzzingpixel/static-cache-clear-ee
addded an PR for that https://github.com/buzzingpixel/craft-static/pull/6
I have the code below working, but it would be preferable if edits only cleared the site currently selected in the CP. Since an editor can switch between sites regardless of the domain they logged into, we can't rely on the host name to determine which site cache to clear. Any plans to add multi-site support? Maybe a simple placeholder that gets replaced into the cache path?
Let's say you have 3 sites,
admin.website.com
,red-pill.website.com
,blue-pill.website.com
. Admin will only be used to access the control panel. The other two sites need to be static cached.The
CRAFT_SITE
constant is defined in a.env
file depending on the value of$_SERVER['HTTP_HOST']
.In the
craft-static.php
config file:When logged in to the admin site, the cache path is the parent of the two other sites. Thus any edits clear the cache for all sites.
Then to rewrite to the static cache files, bypassing PHP:
.htaccess: