The Page Caching Sample In The Last Chapter Needs More Comments

HI

First of all, Thanks for your great Book.

in the page 333 of First release of the Book, there is a sample of page chaching.

since this sample will cache all of the page content including all menus, it generate an small bug in real world.

Example:

  • John login to site and see a project. this page is cached too!

  • Guest user come to site and see a project. the Application shows him a cached page. so Guest user will see in the top menu bar: [b]Logout(John)

[/b]

you know about my mean. and it’s one of my problems in a real app.

I should cache just an Action and just the output of views related to the action without including Layout and so on.

but I don’t know what’s the best solution!

I think it’s possible to resolve the problem using the method below. although it’s not a normal solution.

1- render the view from action, without sending Data to it.

Put the block of fragment caching in the first and last lines of view code.

also all data should be retrieved from DB in the view file! (move them from action to the view file)

in this case, both data from DB and also rendered HTMLs are cached.