Yii Framework Forum: The Page Caching Sample In The Last Chapter Needs More Comments - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

The Page Caching Sample In The Last Chapter Needs More Comments page 333 in the first release of the Book

#1 User is offline   amiri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 57
  • Joined: 08-January 12

Posted 06 June 2013 - 07:42 AM

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: Logout(John)

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users