Update: it looks like my issue relates to cached partials, below is an overview of my problem, but my assumption was incorrect.
I think ive found a bug in umbraco 7.6.0 relating to the way content is cached, hopefully someone can shed some light on this.
I have a team member page which lists any events that this team member is responsible for. I have a lookup for these nodes defined in a seperate file in app_code under an EventUtillities namespace:
var teamMemberCurrentEvents = EventsUtillties.getTeamMemberCurrentEvents(teamMemberId);
It does seem to work, but the minute an event passes the threshold for a current event into a previous event the view isnt updated and still shows the event as a current event.
The method for a previous event is very similar, but a slight change within the date comparision.
Could someone please shed some light on why this could be please, if i restart my machine it does seem to be updated correctly but this isnt a practical fix.
Update: it seems IIS could be the culprit here, as when stopping and restarting the view is correctly updated... Anyone give a basic IIS user any tips on how to set this up correctly?
Still no joy, the partial is being heavily cached.... anything else I can try here please?
Update: Brought all logic over from partial into main page view, and still the caching problem continues...
Update 2: I wondered if umbraco.config was being updated with the publish and unpublish of the node, and it indeed does. Strange that the .config and the views are seemingly seeing different things
Ive extrapolated a lot of my logic into App_Code to clean up my views, plus it gives me a lot of reuseable methods I can call where needed.
Win win right? Well ive made a right schoolboy error and its been a right monster to track down!
My utillities file in App_Code is namespaced like so.
namespace xxx.web.Utillities
{
namespace Events
{
public class EventsUtillties {
/*1*/
public static List<IPublishedContent> teamMemberEvents(int teamMemberId)
{
/*2*/
/code to get all team member events
}
public static List<IPublishedContent> getTeamMemberCurrentEvents(int teamMemberId)
{
/*3*/
/code to get all team members current events
}
public static List<IPublishedContent> getTeamMemberPreviousEvents(int teamMemberId)
{
/*4*/
/code to get all team members previous events
}
}
}
}
This allows me to use it like so:
in the view:
@using xxxx.web.Utillities.Events;
var teamMemberId = Model.Content.Id;
var teamMemberCurrentEvents = EventsUtillties.getTeamMemberCurrentEvents(teamMemberId);
However i noticed i was writing this over and over at places 2, 3, and 4
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var homepage = umbracoHelper.TypedContentAtRoot().FirstOrDefault(x => x.DocumentTypeAlias == "homepage");
So I tried putting it at point 1. which seemed to work (keyword:seemed), didnt think anything of it and carried on as normal but it looks like (and its so obvious now) that the UmbracoHelper taking in the current state of umbraco context and due to the scoping was being accessible to the methods, well that was casing me problems. Which again made sense that when IIS was reset this was refreshed and I was getting the result I expected, only for everything to immediately break again, leaving me with no other option but to wrongfully blame IIS and partial views.
Cached Partials - Umbraco 7.6.0
Update: it looks like my issue relates to cached partials, below is an overview of my problem, but my assumption was incorrect.
I think ive found a bug in umbraco 7.6.0 relating to the way content is cached, hopefully someone can shed some light on this.
I have a team member page which lists any events that this team member is responsible for. I have a lookup for these nodes defined in a seperate file in app_code under an EventUtillities namespace:
Then on the view:
And then called by using:
It does seem to work, but the minute an event passes the threshold for a current event into a previous event the view isnt updated and still shows the event as a current event.
The method for a previous event is very similar, but a slight change within the date comparision.
Could someone please shed some light on why this could be please, if i restart my machine it does seem to be updated correctly but this isnt a practical fix.
Update: it seems IIS could be the culprit here, as when stopping and restarting the view is correctly updated... Anyone give a basic IIS user any tips on how to set this up correctly?
Hi,
How is the code above called - have you got a cached partial? That would definitely explain the behaviour.
Steve
Hi Steve, thanks for the reply!
Yea, the whole block is being called as a partial, trying to keep those views as clean as possible.
What can I do to get around this?
Although looking here - https://our.umbraco.org/documentation/reference/templating/mvc/partial-views
This documentation mentions that if debugging is turned on (which in my instance it is) then caching should be turned off.
Hi,
Yes - it should be.
Just to check are you calling it like:
@Html.CachedPartial("MyPartialName", new MyModel(), 3600)
Or @Html.Partial("MyPartialName")
And it's just a standard page load - e..g you're not fetching the page from AJAX / Angular etc etc?
Might be worth trying something like:
@Html.CachedPartial("MyPartialName", new MyModel(), 10) to see?
Just tried that as described, passing in current page Model:
Still no joy, the partial is being heavily cached.... anything else I can try here please?
Update: Brought all logic over from partial into main page view, and still the caching problem continues...
Update 2: I wondered if umbraco.config was being updated with the publish and unpublish of the node, and it indeed does. Strange that the .config and the views are seemingly seeing different things
Finally sorted it.
Ive extrapolated a lot of my logic into App_Code to clean up my views, plus it gives me a lot of reuseable methods I can call where needed.
Win win right? Well ive made a right schoolboy error and its been a right monster to track down!
My utillities file in App_Code is namespaced like so.
This allows me to use it like so:
in the view:
However i noticed i was writing this over and over at places 2, 3, and 4
So I tried putting it at point 1. which seemed to work (keyword: seemed), didnt think anything of it and carried on as normal but it looks like (and its so obvious now) that the UmbracoHelper taking in the current state of umbraco context and due to the scoping was being accessible to the methods, well that was casing me problems. Which again made sense that when IIS was reset this was refreshed and I was getting the result I expected, only for everything to immediately break again, leaving me with no other option but to wrongfully blame IIS and partial views.
Phew, what a day!
is working on a reply...