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 3752260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:12:57+00:00 2026-05-19T09:12:57+00:00

I have a caching scenario which I’m not sure how to solve. I am

  • 0

I have a caching scenario which I’m not sure how to solve. I am able to cache static pages without a problem but am having a little trouble with dynamic pages.

In the dynamic page the logic goes something like this:

//part1
-some processing for the beg of the page (needed for part 3)
-echo some info

//part2
echo user specific menu + some user specific info

//part3
echo rest of the page

The problem is that if I cache the whole page, and then the cache is read, it is no good (
part2 will be incorrect since it depends on the user).

to cache a page, I just use
“ob_start();” at the beginning of the file, then save ob_get_contents() to a file and then “ob_end_flush();” at the end.
If the file already exists in cache and its not expired, i do: “include(file);” and “exit;”

I tried splitting the caching into two files but parts 2 and 3 depend on some php processing of part1 I’m having a hard time…

Does anybody have any ideas on how to solve this? Please let me know if I’m not being very clear and I will reformulate the question. Thank you!

  • 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-19T09:12:58+00:00Added an answer on May 19, 2026 at 9:12 am

    APC/Redis/Memcached

    If you could you should use APC(and/or Redis/Memcached) to cache your data because it is going to be WAAAAAAAAAAAAAAAAY faster(everything stays in MEMORY). If you want your website to perform good you should have APC(precompiled byte-code in MEMORY) installed anyway.

    Cache_Lite

    Else you should use the excellent Cache_Lite library to cache your data to a file. The introduction explains perfectly how to use it. If it all possible you should write to /dev/shm/ because this maps to MEMORY which is going to be way faster then Disc IO.

    Splitting Cache

    I tried splitting the caching into two
    files but parts 2 and 3 depend on some
    php processing of part1 I’m having a
    hard time…

    You should have unique pieces(exclusively as large as possible would be best, but sometimes hard to keep track off) and then combine these pieces you need on that page. Each piece should have an unique ID off-course(for retrieval).

    <?php
    require_once('Cache/Lite.php');
    
    $options = array(
        'cacheDir' => '/tmp/',
        'lifeTime' => 3600
    );
    
    // Create a Cache_Lite object
    $Cache_Lite = new Cache_Lite($options);
    
    if ($data = $Cache_Lite->get('#{ID for user specific menu}')) {
        echo($data);
    } else {
        $data = 'Data of the block 1-1';
        $Cache_Lite->save($data);
    }
    
    echo('<br><br>Non cached line !<br><br>');
    
    if ($data = $Cache_Lite->get('#{user specific info}')) {
        echo($data);
    } else {
        $data = 'Data of the block 2';
        $Cache_Lite->save($data);
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read the documentation for the CI Caching but still don't understand much
I have enabled site-wide Django caching , but the third-party apps I am using
Here's the scenario I have an ASP.NET 4.0 application which has a LOT of
I have a Rails 3 website, for which the home page is static content
Let's say you have this scenario:a simple blog home-page that loads both static content
I have a scenario where the main website (which I have no control over)
I have a scenario where I am displaying the data in the database which
I have caching enabled on my smarty installation and have following Template Functions function
In particular what strengths does it have over caching features of Asp.net
I have a file caching system for a php application. if a file needs

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.