This week in Orchard - 08/03/2019
Huge steps to make Orchard Core CDN ready and to support Azure Blob Storage provider and many more improvements and fixes in our upcoming post!
On Orchard Core
The plural extension should work with NullStringLocalizer
There is a unit test that shows the issue. When the Localization module is not enabled we are using the
NullStringLocalizer and this case the pluralization was not working correctly.
Reload resource settings on update
When changing the resource settings (CDN/debug mode etc) the current tenant is not reloaded, so the settings don't take effect. The solution here was to just reload the general site settings when they change so that resources will change to debug/CDN/minified, etc. You can find the changes in the
UpdateAsync method of the
Show connection string hint for all data providers
When adding a new tenant or set up a new site, for some providers you need to have a connection string. Now a little hint will help you to type the connection string in the required format.
Make Orchard Core CDN ready
There are two concerns here. One is the Azure Blob Storage provider support and CDN support. These are actually two different concerns. In Orchard 1.x, we used Azure Blob Storage as a CDN, meaning when we would render the media from Azure Blob Storage, we would render the URL from the Azure Blob Storage, so the client would directly download the media from Azure Blob Storage. The Orchard server will not serve the file, the Azure CDN will serve it.
In Orchard Core, we are using ImageSharp as the first middleware that serves the media. Right now when we render a file from Azure Blob Storage, we still render the Azure Blob Storage URL, and in this case, the media resizing doesn't work.
Based on some feedback from the ImageSharp developers they said we are doing it wrong, you should always serve all your media from your server, even if it's coming from Azure Blob Storage. This way the ImageSharp filter be able to convert the images using the given sizes.
When we serve a media, first we load the blob from the server, transform it, cache it locally and finally serve it. The next time when somebody asks for this media, we have it in the cache, so serve it from the cache. In this case, the Azure Blob Storage is not used as a CDN, it is used just like some storage and we have to load it whenever we need to load it. Then we still have the issue of the CDN. How do we do a CDN then, because we can't use Azure Blob Storage as the solution for the CDN?
The solution is just to be able to use ACDN for any media that we render either they are from the local disk or from Azure Blob Storage, they will be always served by the Orchard Core server, but when we generate the URL to the generated media (for instance the resized media) we don't generate our own local URL to access our local cache of the resized file, but we generate a URL to a CDN endpoint (that could be any CDN endpoint, like Cloudflare, Azure, Horizon), that itself is configured to ask our server for the media. So, our only job for the CDN support is to generate a CDN URL. It can be an Azure CDN URL, not an Azure Blob Storage URL.
With this CDN solution, we could work with any storage provider. When the request comes to Orchard with the local URL, it will download the file from the Blob Storage if it hasn't done it yet.
The client cache is active because when we generate these files we had a public cache tag, so the client won't reload the same image again, won't send the same request again. Even if we send a request, it's cached locally on the server, so we won't ask Azure again, just load the file locally.
Orchard Dojo Newsletter
Now we have 86 subscribers of the Lombiq's Orchard Dojo Newsletter! We have started this newsletter to inform the community around Orchard with the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post published to Orchard Dojo, including This week in Orchard of course.
Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here!