Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6391483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:40:37+00:00 2026-05-25T03:40:37+00:00

Is it possible to cache only a specific part of a page in PHP,

  • 0

Is it possible to cache only a specific part of a page in PHP, or the output of a specific section of code in the PHP script? It seems when I try to cache a particular page, it caches the whole page which is not want I want, some of the content in my page should be updated with every page load while others (such as a dropdown list with data from a database) only needs to be updated every hour or so.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:40:38+00:00Added an answer on May 25, 2026 at 3:40 am

    Zend_Cache

    I would probably use Zend Frameworks Zend_Cache library for this.

    You can just use this component without needing to use the entire framework.

    Step over to Zend Framework Download Page and grab the latest.

    After you have downloaded the core files, you will need to include Zend_Cache in your project.
    Zend_Cache docs.

    Have you decided how you want to cache your data? Are you using a file system? Or are you memcache? Once you know which you are going to use, you need to use a specific Zend_Cache backend.

    Zend_Cache Backends / Zend_Cache Frontends

    • You need to use a backend (how you are caching in storage what it is you want to cache) and
    • You need to use a frontend (how do you actually want to cache.. like using a buffer, or caching function results etc)

    Backend documentation: Zend_Cache Backends
    Frontend documentation: Zend_Cache Frontends

    So you would do something like this…

    <?php
    // configure caching backend strategy
    $backend = new Zend_Cache_Backend_Memcached(
        array(
            'servers' => array( array(
                'host' => '127.0.0.1',
                'port' => '11211'
            ) ),
            'compression' => true
    ) );
    
    // configure caching frontend strategy
    $frontend = new Zend_Cache_Frontend_Output(
        array(
            'caching' => true,
            'cache_id_prefix' => 'myApp',
            'write_control' => true,
            'automatic_serialization' => true,
            'ignore_user_abort' => true
        ) );
    
    // build a caching object
    $cache = Zend_Cache::factory( $frontend, $backend );
    

    This would create a cache which makes use of the Zend_Cache_Frontend_Output caching mechanisms.

    To use Zend_Cache_Frontend_Output which is want you want, it would be simple. Instead of the core you would use output. The options which you pass are identical. Then to use it you would:

    Zend_Cache_Frontend_Output – Usage

    // if it is a cache miss, output buffering is triggered
    if (!($cache->start('mypage'))) {
    
        // output everything as usual
        echo 'Hello world! ';
        echo 'This is cached ('.time().') ';
    
        $cache->end(); // output buffering ends
    
    }
    
    echo 'This is never cached ('.time().').';
    

    Useful Blog: http://perevodik.net/en/posts/14/

    Sorry this question took longer to write than expected and lots of answers have been written I see!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the ContainsIngredients method in the following code, is it possible to cache the
Is it possible to clear the output cache of one asp.net web application from
Is it possible to query Google's cache with a specific date range. for instance,
How to decrease the number of possible cache misses when designing a C++ program?
Is it possible to cache the response of a http handler on the server
I heard on a recent podcast (Polymorphic) that it is possible to cache a
Is it possible to clear one action's cache from another action? Let's say my
Is it possible to get the expiry DateTime of an HttpRuntime.Cache object? If so,
I would like to cache my website with memcache as much as possible. There
I want to be able to display the following code below only when a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.