problem with Cache

Topics: Troubleshooting
Aug 9, 2011 at 1:50 PM


We are evaluating composite c1 to replace our old cms.

Our idea is use the Composite c1 API from an external application which will be the one to render the content.

We found a weird problem which is related to the cache system, our code to get the page is :

using (var connection = new DataConnection(PublicationScope.Published, this.defaultCulture))
	var page = connection.Get<IPage>().First(p => p.FriendlyUrl == friendlyUrl);

when we request a page by the friendly url it works fine  the first time, but if you change that friendly url and access to the application with the new friendly url

we got this : 

Sequence contains no matching element

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Sequence contains no matching element

Stack Trace: 

[InvalidOperationException: Sequence contains no matching element]

System.Linq.Enumerable.First(IEnumerable`1 source, Func`2 predicate) +338

System.Linq.EnumerableExecutor`1.ExecuteBoxed() +9

Composite.Data.Caching.CachingQueryable`1.Execute(Expression expression) +373

System.Linq.Queryable.First(IQueryable`1 source, Expression`1 predicate) +590

Com.Model.CompositeCms.CompositeC1DataAccessor.GetPageHead(String friendlyUrl) in CompositeC1DataAccessor.cs:137

Also we have experienced that the new content created is not accessible neither.

Any ideas? Someone have faced a similar problem?


Aug 9, 2011 at 2:03 PM
Edited Aug 9, 2011 at 2:03 PM

The reason for exception is that code 

var page = connection.Get<IPage>().First(p => p.FriendlyUrl == friendlyUrl);

throws an exception if there're no pages that match the rule. If you change it to 

var page = connection.Get<IPage>().FirstOrDefault(p => p.FriendlyUrl == friendlyUrl);
It will return "null" instead of an exception. 

>> Our idea is use the Composite c1 API from an external application which will be the one to render the content.
Do you edit the content from C1's administration console, or doing it also through API?
Could it be that after changing FriendlyUrl field you have forgotten to publish the page? - That would explain why it wasn't found
Aug 9, 2011 at 2:30 PM

hi napernik,

thanks for your quick answer.

We edit the content from the c1 administration console and we have been published the page.

The only way to pick up again the new friendly url is recompiling or rebuilding the external application which make us think that c1 or Linq is caching the query. 

or maybe the DataConnection object is not being disposed correctly.

Thanks again

Aug 9, 2011 at 5:52 PM

That is surprising - we are not aware of any issues here - could you tell me if the repro below do now yield the expected results shown? Please make the ashx as simple as possible to rule out any other components.

1) Edit a page, give it Friendly URL value = "A"
2) Save and publish the page
3) create a super simple *.ashx file and have it execute the code shown below

Expected: "A count: 1, B count: 0"

4) Edit the page, give it Friendly URL value = "B"
5) Save and publish
6) Rerun the ashx page

Expected: "A count: 0, B count: 1"

using (var connection = new DataConnection())
    httpContent.Response.Write( string.Format("A count: {0}, B count: {1}",connection.Get<IPage>().Count(p => p.FriendlyUrl == "A"), connection.Get<IPage>().Count(p => p.FriendlyUrl == "B"));

Aug 10, 2011 at 9:51 AM

Hi mawtex,

Thanks for your reply.

We have tried the example you gave us and the second result is not as expected : "A count: 1, B count: 0" appears instead of "A count: 0, B count: 1".

If it is the expected result then probably the problem will be in our external MVC application. We think it could be related to the IIS7 cache settings or maybe to the external MVC application.


Aug 10, 2011 at 10:12 AM

I'd like to follow this up at our end - could you send me your Composite C1 build number and what data store you use (XML or SQL)?

Aug 10, 2011 at 10:25 AM

Hi mawtex,

Our composite c1 build number is 2.1.4113.99.

We are calling the API from a MVC 3 application.

Composite c1 and the mvc application are in different application pools. 

We are using SQL to store the data, also the friendly url get updated correctly when we publish the page.

Another info that can be useful is that the content of the page get update correctly after published.


Please let me know if you need more information,.


Aug 10, 2011 at 11:40 AM
Edited Aug 10, 2011 at 11:51 AM

You can turn-off the cashing. Edit /App_Data/Composite/Composite.config



<Caching enabled="true">

   <add name="DataAccess" enabled="true" size="-1" />




Change it to


<Caching enabled="true">

   <add name="DataAccess" enabled="false" size="-1" />



>> Our idea is use the Composite c1 API from an external application which will be the one to render the content.

As far as I understand, you will be using only visual editor's part from C1 for editing content, and the content is rendered by one of MVC layouts, is that correct?

Wouldn't it be easier to get the 2 sites running "side by side", so you don't have to use different app pools? 

Aug 10, 2011 at 12:07 PM

@abcamer a little background to the suggestion above - if you are editing content in one app pool and pulling data from another, this is probably the cause of your cache not updating. Content changes only gets advertised in the appPool serving the change request, so your other appPool will not do a cache flush. Disabling caching as napernik suggests could fix this.

Aug 10, 2011 at 12:44 PM

Hi napernik and mawtex,

napernik's solution works for us! thank you very much to both. :)

@napernik: We need different pools to isolate them each other for security reasons, so unfortunately they have to live in different pools.

thanks again.

Aug 10, 2011 at 1:35 PM

Maybe Composite should consider a provider-model for their caching, so you can use out-of-process distributed caching if that's what you need ( Even Microsoft started to go down that road using providers for things like ie. OutputCaching.