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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:15:50+00:00 2026-06-09T03:15:50+00:00

I am working on a site that is built on LAMP, which pulls data(car

  • 0

I am working on a site that is built on LAMP, which pulls data(car dealership inventories) from an XML feed and displays it on the site. There is a rotator on the index page which displays 4 random cars, however there is a long delay on page load – about 7-10 seconds. This is because the site is cycling through the data to find cars that have images and meet other criteria before displaying the results. My developer put together this script to cache the results for 5 minutes:

/* 
 * Cache requests for 5 minutes
 * Wraps original method (now _sendRequest)
 */
private function sendRequest($xml) {
    error_log($xml);
    $cache_filename = dirname(__FILE__) . '/cache/' . md5($xml);
    if (file_exists($cache_filename) && (time() - filemtime($cache_filename)) < 300 && filesize($cache_filename) > 100) {
        return file_get_contents($cache_filename);
    } elseif (file_exists($cache_filename)) {
        unlink($cache_filename);
    }
    $response = $this->_sendRequest($xml);
    if (!is_dir(dirname($cache_filename))) {
       @mkdir(dirname($cache_filename),0775,true);
    }
    @file_put_contents($cache_filename, $response);
    return $response;
}

private function _sendRequest($xml) {
    $options = array(
        CURLOPT_RETURNTRANSFER  => true,
        CURLOPT_CONNECTTIMEOUT  => 120,
        CURLOPT_TIMEOUT         => 120,
        CURLOPT_POST            => true,
        CURLOPT_USERAGENT       => Config::$appName,
        CURLOPT_USERPWD         => Config::$aweAPIKey,
        CURLOPT_URL             => Config::$aweAPIURL,
        CURLOPT_POSTFIELDS      => $xml
    );
    $ch = curl_init();
    curl_setopt_array($ch, $options);
    $content = curl_exec($ch);
    //echo "ERROR: " . curl_error($ch);
    curl_close($ch);

    return $content;
}

The directory of the script is in /lib/client.php and it is saving large amounts of text files containing vehicle data in /lib/cache, however the site page load is not decreasing. Are there some changes I should make to the script or how it is saving the cached data?

  • 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-06-09T03:15:52+00:00Added an answer on June 9, 2026 at 3:15 am

    Hitting the hard disk with every request is expensive in terms of performance, so logically your cache system there isn’t really gonna help. Instead look into APC, memcached or Redis as they allow you to store data directly in memory, which is much faster to read and write.

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

Sidebar

Related Questions

I'm working on a site that I've inherited that's built with ASP.Net, which I'm
I'm working on a fairly large web site built in PHP that will potentially
I'm working on a site that pulls various public RSS feeds down. I want
I am currently working on a site that is being built on codeigniter, I
A site I am working on that is built using PHP is sometimes showing
Yeah, this ought to be fun. I'm working on a site that was built
I'm working on a static site/web app right now that is being built with
I'm working on a Wordpress site which has various features that are only available
Ok Im working on a site that has a sidebar and a main content
I'm working on a site that sells various products. Currently we're presenting those products

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.