Smidge - Configuring bundles in V13
d
How do we configure bundles now? I was adding config in Startup.cs e.g.:
Copy code
services.Configure<SmidgeOptions>(options =>
            {
                options.DefaultBundleOptions.ProductionOptions.FileWatchOptions.Enabled = true;
                options.DefaultBundleOptions.ProductionOptions.SetCacheBusterType<AppDomainLifetimeCacheBuster>();
                options.DefaultBundleOptions.ProductionOptions.CacheControlOptions.CacheControlMaxAge = 12000;
            });
But am no longer using Startup files. I have tried in the notification handler and I'm down to a single syntax error, undoubtedly a terrible way to do it but I'm trying to learn the new way as I go. FWIW other than this I have Smidge minifying and bundling as it should do ht @AaronSadlerUK https://cdn.discordapp.com/attachments/1212081950794194994/1212081951251501166/image.png?ex=65f08a48&is=65de1548&hm=8051eefc44db1ed4afb92c0c39c87868a57c0f9b993fe9fefd52c94b114c2c01&
s
Composers! Not tested but should work:
Copy code
csharp
using Microsoft.Extensions.DependencyInjection;
using Smidge.Cache;
using Smidge.Options;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;

namespace MyNameSpace;

public class BundleComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.Services.Configure<SmidgeOptions>(options =>
        {
            options.DefaultBundleOptions.ProductionOptions.FileWatchOptions.Enabled = true;
            options.DefaultBundleOptions.ProductionOptions.SetCacheBusterType<AppDomainLifetimeCacheBuster>();
            options.DefaultBundleOptions.ProductionOptions.CacheControlOptions.CacheControlMaxAge = 12000;
        });
    }
}
d
Thanks @Sebastiaan will give it a try
Hey @Sebastiaan whilst I see no errors this still does not seem to be updating the Cache-Control header value (just the Smidge default value). This is my Program.CS - I wonder if it is an order of execution issue?
Copy code
using Umbraco.Cms.Core.Notifications;
using Umbraco.Docs.Samples.Web.Stylesheets_Javascript;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

builder.CreateUmbracoBuilder()
    .AddBackOffice()
    .AddWebsite()
    .AddDeliveryApi()
    .AddComposers()
    .AddAzureBlobMediaFileSystem()
    .AddAzureBlobImageSharpCache()
    .AddNotificationHandler<UmbracoApplicationStartingNotification, CreateBundlesNotificationHandler>()
    .Build();

WebApplication app = builder.Build();

await app.BootUmbracoAsync();


app.UseUmbraco()
    .WithMiddleware(u =>
    {
        u.UseBackOffice();
        u.UseWebsite();
    })
    .WithEndpoints(u =>
    {
        u.UseInstallerEndpoints();
        u.UseBackOfficeEndpoints();
        u.UseWebsiteEndpoints();
    });

await app.RunAsync();
s
does it work when you put it in
Program.cs
instead?
d
Again no errors but also doesn't work, same using it in the Notification Handler. I am tempted to create a StartUp.cs but feel like it's a step backwards
s
So it's just not working. You don't need a Startup.cs, you'll get the same result 🙂
d
I have it in StartUp in other sites bit I just cjecked on where I have it set to 12000 and its
Copy code
Cache-Control:
public, max-age=43200000, s-maxage=43200000
Yet this site is
Copy code
public, max-age=864000, s-maxage=864000
Which I think is the Smidge default
324 Views