New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds asp-append-version support #3581
Conversation
…n. AppendVersion remains useful on ResourceManifest that also uses Version as when providing debug-src url's are not versioned
… so UseStaticFiles can resolve correct IFileProvider, in case another IFileProvider registered earlier (no conflict with media or custom registration in Cms.Web for example)
…added OrchardCMS#8177 / OrchardCMS#8177 from Orchard V1
… within markdown & html body
…add the OC FileVersionProvider
… file provider manifest to once per tenant = false
src/OrchardCore.Modules/OrchardCore.Media/Filters/MediaFilters.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Media/Filters/MediaFilters.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Media/Filters/MediaFilters.cs
Outdated
Show resolved
Hide resolved
Just tried, i could see the style / script appended versions when under the admin, looks very good. I may not have so much time this week (administrative things in late) but i will review it asap, maybe step by step. Right now i just reviewed the |
…o provide additional path base information to IFileProviders if required.
@jtkech Thanks for the quick look and comments! I've since implemented the
I also implemented the same And done some code cleanup (my bad) Cheers appreciate the time it takes to review! Busy week for me on other things as well. |
I like it 👍 just did some refactoring on my side that i will explain through comments or a review coming soon. Please don't push other updates because i did the changes on my side for testing, so would be better that i could push them to your branch, or create a branch on my side that you will merge. |
src/OrchardCore.Modules/OrchardCore.Media/Filters/MediaFilters.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Tenants/Services/ITenantFileProvider.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Abstractions/Modules/IModuleStaticFileProvider.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Abstractions/Modules/ModuleCompositeFileProvider.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ResourceManagement/FileVersionProvider.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ResourceManagement/FileVersionProvider.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ResourceManagement/ServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore/Modules/Extensions/ServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore/Modules/Extensions/ServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
As said above i did the changes on my side for testing, so we will see tomorrow how we can share my work so that you can review it. |
@jtkech Great, review looks very good - I'm still figuring out where to put things in the many Orchard Projects. Really good to move Also I had named it I think maybe your review allows me to clean up a few other things so maybe when you are finished reviewing, if you pull request my branch, then I can tidy up some more things that occur to me now. Regardless I make no more commits to this PR while you are still looking through it. Also still not sure if I need to add so many File Watchers for Not Found files, but seemed useful (especially for testing by dropping missing files into folders), but if you have any thoughts on this be great. |
I did some answers on the review.
I renamed it to
Okay.
Yes, useful in dev mode (or not) for files that are still physical files, so that the token is invalidated when the file is removed / added. Hmm, maybe not so useful in prod because most of the files are embedded, but there are app level static files, tenant specific ones and medias, so right now let keep it, will see. Update: Do we have to update all razor / liquid views to use the append version attribute? Or later in another PR ;) Update: I pushed my updates on your branch, please review them, i may have missed something, did wrong things, some comments not correctly updated, and maybe re-do some tests. |
I forgot it me too ;) I let you test it, let me know when you are ready with this last change so that i can approve this PR, then for merging it we will have to wait for @sebastienros ;) Update: Next PR
|
@jtkech Tested again this morning, and all working well, so for me it is ready. Cheers for your herlp getting it knocked into shape! @sebastienros FYI, below is screenshot for Resource Cdn settings - this is the only visual change in the admin.
Yes, @sebastienros as discussed, input when you are ready on design :) Other Next PR |
I agree that source maps should be generated separately from minified assets. The source maps should be only usefull for dev purpose and never be published on prod websites. The gulp pipeline as it is has been migrated from 01 and has only been slightly modified for OC. I'm opening an issue for this and other issues reported with the gulp pipeline. |
So basically this feature is : cache busting for assets. |
Yes, and the new conflict is because of my last PR ;) |
Ohh you bad french people! 🍪 🍪 |
Ok I tested this PR and with Liquid so far everything works fine. |
@Skrypt Yes cache busting for js/css and media assets Cheers for testing 😄 I'll resolve merge conflict shortly |
Oh also, you should be able to see it working with razor on the admin page layout e.g.
Note Only the admin |
I was looking at the assets for our Admin theme and there's probably things that could be bundled together. The frontend themes have the same issue but we kept the templates as close as they we're built without really optimizing them properly by using only one .js file and one .css file per template. We have a gulp pipeline but we are not using it optimally. As for CDN for assets, the more you add external libraries in your HTML the more requests you get on your page and the slower it gets. So far it has always been faster for me to bundle everything in one file if I could. I'm going to work on something today. At least fix the issues that we all have with Bootstrap versions. |
Couldn't agree more. Good luck in the seventh circle of npm hell! |
I think @sebastienros wants to look at the files watcher code before merging. It's working nicely on my website on prod as of now but I'm not using Azure Blob Storage yet. |
ah good to know it's working! The file watcher code is straight out of the asp-net default handler. I think it watches every 4 seconds (might be 2). I do question how useful it is to have a file watcher running on the media dir. Could just as easily do the cache clearing from the |
Please merge when the conflicts are solved. We'll still need to add the CDN settings for the Media items. |
Okay, i will do |
# Conflicts: # src/OrchardCore.Modules/OrchardCore.Media/Startup.cs # src/OrchardCore/OrchardCore.Mvc.Core/Startup.cs
* MediaFileStoreVersionProvider and FileVersionHashProvider * WIP. Add IFileVersion to ResourceManager and Tag Helpers * WIP Update ResourceManifest and admin layout to use asp-append-version. AppendVersion remains useful on ResourceManifest that also uses Version as when providing debug-src url's are not versioned * create IModuleStaticFileProvider and provide registration identifiers so UseStaticFiles can resolve correct IFileProvider, in case another IFileProvider registered earlier (no conflict with media or custom registration in Cms.Web for example) * WIP. Media ImageHelper working but needs further testing * add ImageVersionProcessor suggest by jtkech. Tested works well * Fixes OrchardCMS#3434 Setting the right resource key in debug mode - added OrchardCMS#8177 / OrchardCMS#8177 from Orchard V1 * add liquid tag helper for append_version * updated LiquidFilter to work via httpContextAccessor to support media within markdown & html body * implement cache / tidy up mediafilter * remove IFileVersionHashProvider, and Replace, rather than remove and add the OC FileVersionProvider * renamed MediaFileImageProvider to MediaResizingFileProvider * add CdnBaseUrl support for prepending a base cdn url to assets * update documentation, and support append-version with AssertUrl Helper * documentation tweaks * more documentation tweaks * add support for tenant static file provider, and change tenant static file provider manifest to once per tenant = false * Add support for IVirtualPathBaseProvider as a better generic filter to provide additional path base information to IFileProviders if required. * Code cleanup * Refactoring * Minor changes. * Refactoring ShellFileVersionProvider * Refactoring, rename ImageTagHelper Attribute asp-append-version * Also use a shared cache for module static files. * Minor change. * Add support for AppendVersion to Link Tag Helper * Little formatting after merging dev.
* MediaFileStoreVersionProvider and FileVersionHashProvider * WIP. Add IFileVersion to ResourceManager and Tag Helpers * WIP Update ResourceManifest and admin layout to use asp-append-version. AppendVersion remains useful on ResourceManifest that also uses Version as when providing debug-src url's are not versioned * create IModuleStaticFileProvider and provide registration identifiers so UseStaticFiles can resolve correct IFileProvider, in case another IFileProvider registered earlier (no conflict with media or custom registration in Cms.Web for example) * WIP. Media ImageHelper working but needs further testing * add ImageVersionProcessor suggest by jtkech. Tested works well * Fixes OrchardCMS#3434 Setting the right resource key in debug mode - added OrchardCMS#8177 / OrchardCMS#8177 from Orchard V1 * add liquid tag helper for append_version * updated LiquidFilter to work via httpContextAccessor to support media within markdown & html body * implement cache / tidy up mediafilter * remove IFileVersionHashProvider, and Replace, rather than remove and add the OC FileVersionProvider * renamed MediaFileImageProvider to MediaResizingFileProvider * add CdnBaseUrl support for prepending a base cdn url to assets * update documentation, and support append-version with AssertUrl Helper * documentation tweaks * more documentation tweaks * add support for tenant static file provider, and change tenant static file provider manifest to once per tenant = false * Add support for IVirtualPathBaseProvider as a better generic filter to provide additional path base information to IFileProviders if required. * Code cleanup * Refactoring * Minor changes. * Refactoring ShellFileVersionProvider * Refactoring, rename ImageTagHelper Attribute asp-append-version * Also use a shared cache for module static files. * Minor change. * Add support for AppendVersion to Link Tag Helper * Little formatting after merging dev.
This adds
asp-append-version
support to media, style, and script tag helpers, and liquid filters, through providing a replacement for the MVCDefaultFileVersionProvider
, and adaptions to the various filters, tag helpers, andResourceManager
It replaces #3172 as @jtkech has provided lots of advise as we've come up with a better way to achieve this.
It covers issues which are collected together in #3537 regarding asp-file-version support
Media is covered through changes to the
ImageTagHelper
Scripts and styles, are covered through changes to the Tag Helpers and a new property on the
ResourceSettings
ofUseAppendVersion
so it can also be configured through code.I've updated the admin theme and
ResourceManifest
toUseAppendVersion
- it is helpful also for registered resources, as will provide a version tag when in debug mode and serving, for examplejQuery
which in debug mode does not have a version string in our local path to it. More updates to do to other Admin related views in other modules, if we want to use this as a default feature.It also adds a cdn base path property to
ResourceManager
and site settings to allow only locally assets to be prefixed with a default cdn url. (to see in action just use yourhttps://localhost
address as the base)And while I was there I added the code from O1 OrchardCMS/Orchard#8176 to support better resource bundling from issue #3434
@jtkech I've left #3172 open for the moment as we have so many discussions about further supporting blob storage. Cheers for all your help! (and probably more help with reviewing!)