Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesUsing partial rendering and cachingUsing partial rendering and caching
Previous
 
Next
New Post
3/5/2014 8:07 AM
 

Hello,
in a custom module I have "enable partial rendering" (ajax) enabled, and can use an UpdatePanel which gets updated without reloading the page - perfect.

I now want to add caching to this module: I know there are alerts telling me that caching can cause issues with ajax, but I'd like to understand a little more.
If I set a positive caching time in my module configuration, say 300 seconds, this module works very well: AJAX is working and caching too, but this only if I am in EDIT mode on page. As soon as I switch to VIEW, ajax calls stop working.

Simply.. why? What prevents me to let it work in view mode too?
I now am using datacache setting a static caching time in my module, so it's 0 in module settings, and this way I can get both working, but of course I'd like to go the other way. Should I leave partial rendering?

Regards,

al.

 
New Post
3/5/2014 8:26 AM
 
I don't know - but I will make a guess.



I think that when you are in edit mode DNN turns off the caching.



So out of edit mode what happens? An Ajax updatepanel, in essence, sends the exact same request to the server that a postback would - firing all of the server side events. It then prunes the response to just the parts affected in the updatepanel and sends this smaller reply to the browser. Script at the browser glues the reply back into the page.



My bet is the cache gets in the way. It sees the incoming request and simply says "I know what the answer is for you". no server events fire because the request has already been turned round. The cache sends back a FULL page of html - not the pruned version. The script on the page now doesn't see the response it expects and - like most javascript - just does nothing with no error message.



To anyone sitting in front of it, it just stops working.



If you care to check this out - fire up fiddler and watch the traffic to/from the server in the two situations.



What you are doing seems wrong to me. Turning on the cache essentially says "I don't need the application to do anything for me." Wanting the events says "I want the application to do work for me." You cannot have both.

Best wishes,
- Richard
Agile Development Consultant, Practitioner, and Trainer
www.dynamisys.co.uk
 
New Post
3/5/2014 9:16 AM
 

Richard,

thanks for your reply. I don't know if caching is disabled in Edit mode, probably it is... for sure I was making something wrong, not considering what module caching actally does - cache all module output, not only data.

I was wrong assuming module caching is only about using Datacache within my module, that is I was thinking that only what I explicitly put to cache by calling Datacache.Setcache()  was to be cached, not my entire module output.

What is interesting, to me at least, is that I can however use Datacache to cache my data and take advantage of a performance boost: I'm caching the results of an heavy db call, and reloading data from cache improved loading times a lot. But I cannot set my caching time in module settings (not as Dnn cachetime I mean, I could have a custom settings for this), if I have partial rendering enabled - now I got it.

What I miss now is wheter using Datacache this way hides some problem I cannot see: it sure is not a best practice, but am I the only one using caching this way? Somehow "partial caching" I'd say. 

Wouldn't it make sense to have the possibility to set a "level" for Module output caching, like "Normal" to cache the entire module (like Dnn does now) or "Only data" to only cache data I put in cache calling SetCache? This way I could take advantage of both partial rendering and caching. 

Wrong?

Regards,

al.

 
New Post
3/5/2014 9:26 AM
 
If your major interest is in caching the result of a heavy DB call then I suggest using the standard ASP.Net Cache object. It is built for the job.

Best wishes,
- Richard
Agile Development Consultant, Practitioner, and Trainer
www.dynamisys.co.uk
 
New Post
3/5/2014 9:40 AM
 

Richard,

I will dig into this, thank you. Don't mean to bother you, but... what's the difference? I mean the result is caching my data, but I believe using DataCache is better because Dnn can automatically clean cached items via the cleanup schedule, while I'd expect using asp.net cache would not do the same.

Wrong again? ;)

al.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesUsing partial rendering and cachingUsing partial rendering and caching


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Content Layout

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out