putyourlightson / craft-blitz

Intelligent static page caching for creating lightning-fast sites with Craft CMS.
https://putyourlightson.com/plugins/blitz
Other
150 stars 36 forks source link

Root cache files are not created if baseURL is set to "" #413

Closed Gnative closed 2 years ago

Gnative commented 2 years ago

So I have this interesting scenario where I need all urls to be root relative for Remote Deployment to a different domain.

I have read the article for deploying to Netlify and used entry uri's for linking to entries but there is a gotcha when using the Redactor Editor and linking to entries. There Craft likes to add the full current domain url, which for obvious reasons will not be good to deploy to another domain.

What I've found is that if I set baseURL for the Craft config to an empty string then Craft will create all urls as root relative, even with the Redactor plugin.. pretty handy. Don't even need to use entry.uri as we can then use entry.url

Only issue is that Blitz wont create the root cache files if the baseURL is set to this empty string.

I am running a multilingual site and the other language cache files are being created fine under prefixes of /de/ /fr/ etc.

Am I missing a config or maybe something with Included URI Patterns that might work. Currently set as .* I have tried a few options with no luck and this is the last piece of the puzzle to get everything working smoothly.

Thank You 🙏

bencroker commented 2 years ago

Hmm, let me look into what the issue might be or what might need to be added to make this work. Are you running the latest version 4.1.2 of the plugin?

Gnative commented 2 years ago

Thanks Ben.

I'm on Craft 3.7.42, Blitz 3.12.4.. Still need to migrate to Craft 4.

bencroker commented 2 years ago

Blitz 3 isn't getting new features, so I suggest scheduling in some time to perform the update. I'll let you know what I find in terms of your request.

Gnative commented 2 years ago

@bencroker I've update to Craft 4.. still the same thing as above..

Thou I'm experiencing another issue with "putyourlightson/craft-blitz": "4.1.2" - the generate cache in Utilities and via an API endpoint is not creating a fresh cache.

Tested against with a completely fresh install and only Blitz installed. Only settings changed was to Enable Caching. and to add .* to Included URL patterns. (Maybe making this a default addition to save confusion for new installers)

Visiting "/" home page does create a single cached page for index.html.

bencroker commented 2 years ago

A wildcard URL pattern is written as .*. If testing locally, the you may need to use the Local Generator, since HTTP requests may be blocked.

Gnative commented 2 years ago

OK cool thanks, got the cache generation working now - I did use .*..

Local Generator, thanks. Small difference from Craft 3 as it worked with the original settings there.