Свежайшие Пирожки от CakePHP по-русски

Полнейшее руководство CakePHP 1.2 на русском языке, горячие новости и полезные статьи

Marking Non-Cached Content in Views

There will be times when you don't want an entire view cached. For example, certain parts of the page may look different whether a user is currently logged in or browsing your site as a guest.

To indicate blocks of content that are not to be cached, wrap them in <cake:nocache> </cake:nocache> like so:

Простой текст
  1. <cake:nocache>
  2. <?php if ($session->check('User.name')) : ?>
  3. Welcome, <?php echo $session->read('User.name')?>.
  4. <?php else: ?>
  5. <?php echo $html->link('Login', 'users/login')?>
  6. <?php endif; ?>
  7. </cake:nocache>

It should be noted that once an action is cached, the controller method for the action will not be called - otherwise what would be the point of caching the page. Therefore, it is not possible to wrap <cake:nocache> </cake:nocache> around variables which are set from the controller as they will be null.