Express has a builtin cache mechanism, set up with app.enable('view cache'). But how do you discriminate between views which should be cached and views which should always be served fresh?
I don't know the details, but I think it caches everything. What I mean is that it puts all views inside memory. I don't think you should discriminate between views and should just cache all views. If you don't want this, you could just do the caching yourself by putting them in memory or Redis or something.
But I would advice you to fill issue at Github. I bet TJ will response to that at Github, but does not read this, because at Github he gets email and Stackoverflow he does not.
Views which are mutable should not be cached; only views which are static should be cached. It's up to your application to determine which is which.
Related
CI (2.1.3) & HMVC (5.4)
I have tag cloud (/application/modules/tags)
This module displayed in the template as a block — Modules::run('tags')
If I use $this->output->cache(60) in controller, it cache all page (not tag cloud view).
How can I use blocks caching?
There is no way to do it with Codeigniters built in caching, it only allows you to cache full pages. You need to go and get yourself phil sturgeons partial caching library. https://github.com/philsturgeon/codeigniter-cache, this will let you cache whatever you want.
The only downside is that if your not careful, it can be a bit of a pain to maintain as the site grows, so think carefully about when you are going to need to clear various caches.
We are currently reworking a WebForms based application to a MVC3/Razor system, and have hit a minor issue.
In our current solution, we have a large number of resources held within an external CMS that are compiled into our .aspx pages via a GlobalResource handler; this means that the hit on the CMS is low, and that the resources are only ever needed to be collected once for each individual page.
We can't seem to find any mechanism within Razor/MVC3 that would allow us to do the same thing - any pointers?
I'm not 100% sure I understand your question, but it sounds like you are using an HttpHandler to serve up a bundle of resources. There's no reason that code can't continue to work in MVC3 as-is. If you're doing something else, I'll need a little more clarification :). What's the underlying goal? To reduce the number of Http Requests per page?
I would like to use the output caching function in CodeIgniter, it is simple & fast enough for my application. But the problem is CodeIgniter will push all cached files (hashed names) into the same folder, that will be a problem in my case where I have to cache about 150.000 static pages.
That huge number of the cached files does obviously slows down the process for each request. In my case, I can separate these static pages into multiple categories, so I am thinking of if I can handle CodeIgniter cache to work over the multiple cache folders, it would speed up the process.
Can anyone help me with any suggustion?
Thanks and regards,
Leo
If you really want to separate your cache files into subfolders, MP_Cache (http://hg.mijnpraktijk.com/mp_cache/overview) might help you. But be warned that MP_Cache is no longer maintained by the author.
In my MVC3 Project I use some output caching with the OutputCache attribute set on the action. However there are certain sections on this page that I dont want to cache ever.
Is it possible to have some partials in my view that overrides the pages caching?
You can now get proper donut caching by downloading the MvcDonutCaching NuGet package. See http://mvcdonutcaching.codeplex.com/ and http://www.devtrends.co.uk/blog/donut-output-caching-in-asp.net-mvc-3 for more information.
Yes you are 'supposed' to be able to do this.
See:
Partial Views Caching in ASP.NET MVC 3
Also I use a method to disable caching for controllers here:
Disable browser cache for entire ASP.NET website
Seems like this is the answer: http://weblogs.asp.net/scottgu/archive/2006/11/28/tip-trick-implement-donut-caching-with-the-asp-net-2-0-output-cache-substitution-feature.aspx
You basically have two options:
Refactor the page so that rather than caching the entire page,
you identify all the specific pieces (controls, partials, etc) that
should be cached. (boo)
Use output substitution blocks as Scott
Guthrie describes in the link. (boo as well unless the replacement
is just simple text)
This is called donut caching and isn't supported out of the box in MVC3. Check out my similar question here. Specifically, Jan Jongboom's Moth library which he suggests can do this (though I cannot confirm or deny this)
Of course we can do this, but is it alright to do so? Are there any downsides of this approach?
What do you mean by session data? What programming language on the server (if you are referring to session data on the server)?
If you are using PHP, then you'll need to just call a PHP file with AJAX and delete using unset() (such as unset($_SESSION['user_id']) what ever you need to. I see this as just as risky as doing it with a normal request.
There's no reason you can't do this. The only concern would be that you'd need to handle any page state changes (like removing the 'account' links, etc).