Dnn.Platform icon indicating copy to clipboard operation
Dnn.Platform copied to clipboard

[Bug]: Module caching and ClientResourceManager don't play together

Open donker opened this issue 3 months ago • 0 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

What happened?

The ClientDependencyFramework (CDF) was originally designed for Webforms (WF). The WF controls such as DnnCssInclude do two things:

  1. They register the resource in CDF
  2. They render as a commented out HTML blurb with the supplied parameters

We also have the ClientResourceManager (CRM) which is a programmatic API that allows developers to add resources to a page output. The parameters are more or less the same because they do the same thing under the hood. But, the CRM doesn't leave the blurb as under 2.

Ad 2. Why the blurb?

Well, this blurb is used in module caching. In ModuleHost.cs we check if a module is cached or not. If it is, the cached value (a rendered HTML string of the module) is retrieved and parsed for these blurbs so the resources get added to the page.

What is the problem?

If you add resources through the CRM and module is cached, these resources will not be added to the page output on subsequent requests. If you use module caching you need to use the controls. This is a problem for MVC modules.

Secondly we are unnecessarily adding blurbs for skins as these never get used in caching. This is not a big issue, but it does lead to unnecessary page bloat.

Steps to reproduce?

  1. Create a module and use the CRM to add a resource (css or js file)
  2. Instantiate the module
  3. Switch on module caching for the module
  4. Set caching to heavy/whatever for your site
  5. Load page and see the resource loaded
  6. Refresh page and see the resource not being loaded

Current Behavior

No response

Expected Behavior

No response

Relevant log output


Anything else?

No response

Affected Versions

Current development branch (unreleased)

What browsers are you seeing the problem on?

No response

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

donker avatar Sep 05 '25 11:09 donker