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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:01:23+00:00 2026-05-31T23:01:23+00:00

I need a solution for caching PHP info on a dynamic page AND include

  • 0

I need a solution for caching PHP info on a dynamic page AND include the meta info. My problem is I am using a caching code that is saving my page info from the code and below, but not the meta info.

look at my page My Dynamic Page

My software is dynamically creating this page from the ID 5351 (the song in my database) I am using php to go grab the song info. To make this process a bit more efficient, I have set up PHP caching. I am caching this now using the below code….

<?php

  $cachefile = "cache/".$reqfilename.$cache_folder.md5($_SERVER['REQUEST_URI']);


  $cachetime = 11000 * 60; // 110000 minutes


  // Serve from the cache if it is younger than $cachetime

  if (file_exists($cachefile) && (time() - $cachetime
     < filemtime($cachefile))) 
  {

     include($cachefile);


     echo "<!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." 
     -->n";


     exit;

  }

  ob_start(); // start the output buffer

?>

The PHP Cache is being accomplished using this, but my problem is it only caches the PHP info from this code and below. The reason this is a problem, is because i also use PHP in the meta info for my Open Graphic tags. The OG is so people can “like” my music in Facebook. Here is what my OG tags look like.

<title>Chennai Christian Radio</title>
<meta property="og:title" content="<?php echo $song->title; ?> by <?php echo $song->artist; ?> - Found on Chennai Christian Radio"/>
<meta property="og:type" content="song"/>
<meta property="og:url" content="http://chennaichristianradio.com/PHP/web/songinfo.php?songID=<?php echo $song->ID; ?>"/>
<meta property="og:image" content="<?php echo $song->picture; ?>"/> 
<meta property="og:site_name" content="Chennai Christian Radio"/>
<meta property="fb:admins" content="1013572426"/>
<meta property="og:description"
      content="Chennai Christian Radio is your last stop for today's best Christian Music. http://chennaichristianradio.com"/>

So…… What is the solution for caching my dynamic page AND include the meta info. That is defiantly the best option, but with my current code, it still queries my MYSql server for the Meta info and the song info. I thought by creating static pages for this and telling my software to point to these pages instead of querying my database it would be more efficient, as well as help in reducing my PHP traffic back to my server. Thank you for any help that can be offered.

  • 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-31T23:01:24+00:00Added an answer on May 31, 2026 at 11:01 pm

    If you want to achieve that you should cache the the final html page created by your php script or you could also look into varnish cache.

    If you want do this using php then what I will do is start output buffering and write the contents of the output buffer to cache just before sending to client. Something like the following(pseudocode)

        <?php
    
      $cachefile = "cache/".$reqfilename.$cache_folder.md5($_SERVER['REQUEST_URI']);
    
    
      $cachetime = 11000 * 60; // 110000 minutes
    
    
      // Serve from the cache if it is younger than $cachetime
    
      if (file_exists($cachefile) && (time() - $cachetime
         < filemtime($cachefile))) 
      {
    
         include($cachefile);
    
    
         echo "<!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." 
         -->n";
    
    
         exit;
    
      }
    
        // cache miss
    
        ob_start(); 
    
        // your code logic here
    
        // your views
    
        // at very end
    
        // write the ouput buffer content to cache file
        file_put_contents($cachefile, ob_get_contents());  
        ob_end_flush(); // this will send the response to client
        }
        ?>
    

    I hope the above pseudocode helps

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

Sidebar

Related Questions

We need a caching solution that essentially caches data (text files) anywhere from 3
I need a solution to read raw binary from any filetype stored on a
Folks, I need a solution that allows drag-and-drop cell over the table. The cells
I need to code a solution for a certain requirement, and I wanted to
I'm building a custom page caching utility that uses a syntax like {Substitution:GetNonCachedData} to
I was looking for HTML/Text content caching for small-mid size site using php. I'll
Scope: PHP-mysql based site, using memcached. Caching issue is mostly about prices. Because of
I need some help in picking the 'right' solution for the following 'problem'. I
In a simple PHP caching (with ob_start and files), I need parts (more -or
Issue is SOLVED: Problem is that it is a pre-compiled web page project and

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.