php - Disable cache ONLY in header

799

I know this is a wide question, but I'd like to know which approach you take for achieving this.

Currently I am developing a project which is cached with WP Super Cache plugin. In the header (which is displayed, of course, in every page), there's a message that says "Hello 'nameoftheloggeduser'". I don't want to cache this part of the code, so as the message changes if you log out or if you log in with another account.

<ul id="user-menu" class="menu">
    <?php if ($up->current_user->ID == 0) : ?>
       <li><a href="<?php echo get_permalink($up->signup_page) ?>">Sign 
       Up</a></li>
       <li><a href="<?php echo get_permalink($up->profile_page) ?>">Log 
       In</a></li>
       <?php else : ?>
       <li><a href="<?php echo get_permalink($up->profile_page) ?>">Hello, <? 
       = $up->current_user_data->first_name ?></a></li>
       <?php endif; ?></ul>

Any idea?

724

Answer

Solution:

According to the WP Super Cache, static html pages are only served to users who are not logged in so I don't think you have anything to worry about.

People are also looking for solutions to the problem: php - mySQL: insert values into 2 tables with foreign key relationship

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.