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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:12:51+00:00 2026-05-26T14:12:51+00:00

Using a caching plugin for my wordpress site reduced the server load by quite

  • 0

Using a caching plugin for my wordpress site reduced the server load by quite alot, but I’m trying to reduce it even more. The caching plugin creates a static html file that can be re-used rather than re-creating it with php every single request.

I want to copy this static file to multiple servers so it can be served from multiple locations, thus spreading server load.

The concept

concept

I’m basically doing it like this:

Main server:

//Echo's what the pointer server will echo, which echo's what the sub-server echo's (which is the stored html file's content)
echo file_get_contents("http://$pointerserver?f=$fileNameWeAreRequesting";

Pointer server:

if(isset($_GET['f'])){ $requestedfile = $_GET['f']; }
/* Redirect user to file */
if(isset($_GET['redirect']))
{
    //Filename example: file.html (shares same filename as it's original, 
    //but the content holds a string of sub-servers that host the file, seperated by a comma)
    $servers = file_get_contents("filelocations/$requestedfile");
    $pieces = explode(",", $servers); //Sub-Servers to array
    //Check for online server
    foreach ($pieces as $server)
    {
        if(file_get_contents("servercheck/$server") == "1") //Check if sub-server online
        {
            /* Echo file from sub-server NOW */
            echo file_get_contents("http://$server?f=$requestedfile"); //Echo's whatever the sub-server echo's
            break;
        }
    }
}

Sub-server

/* Provide requested file */
echo file_get_contents("files/$requestedfile"); //Echo's the static html page stored on the sub-server
  1. Does this even reduce the load on the main server at all? Or does file_get_contents work in such a way that the main server ends up “parsing”(putting together the file for html output) the file anyway.

  2. How can I add a check so that if the sub-server is offline without the pointer server knowing about it, we serve the static html file from the main server instead.

Making the main server ready for this

main-server-cdn-ready

The caching plugin handles the making of the static file, so for sending it I was thinking:

Main server:

//This doesn't send anything physical, just instructions to what file the pointer server needs to retrieve and then copy over to the sub-severs.
echo file_get_contents("http://$pointerserver?propagate&f=$fileNameWeAreRequesting";

Pointer server: (I know this doesn’t work, it’s to illustrate the idea)

    if(isset($_GET['f'])){ $requestedfile = $_GET['f']; }
/* Propagate file to sub-servers */
if(isset($_GET['propagate']))
{
    if ($handle = opendir('subservers/')) //Retrieve all available sub-servers
    {
        while (false !== ($server = readdir($handle))) //For-each subserver, send the file
        {
            if ($server != "." && $server != "..") 
            {
                /* CREATE AUTO-SUBMIT FORM HERE TO POST FILE CONTENTS (CONCEPT) */
                action="http://$server/receivefile.php?f=$requestedfile&send"
                $postThisStuff = file_get_contents("http://www.mainserver.xx/cache/$requestedfile"); //Reads the file contents from the main server so it can send it over to the sub-server
            }
        }
    }
}

The sub-server

/* Receive file */
if(isset($_GET['send']))
{
    //Write received post date to file
    $fh = fopen("files/$requestedfile", 'w') or die("can't open file");
    $stringData = $_POST['thefile'];
    fwrite($fh, $stringData);
    fclose($fh);
    die();
}

So my third and final question is; is this copying method a good approach, resource-wise? The static files on the main server rarely change, only when someone posts a comment or an article is edited (or a new one added) but it’s still important to be resource-conserving.

  • 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-26T14:12:52+00:00Added an answer on May 26, 2026 at 2:12 pm

    first off, I had to up-vote the answer for the great presentation. Your idea is not bad either, but still: to answer your question: “Don’t do it!”.

    1. If the WP plugin is configured to write actual HTMLs of the page, use them first? E.g. bypass the entire PHP stack by checking if a html file exists which could be served for the current request. Apache, Nginx or Lighttpd support this by means of URL rewriting (or even in core in terms of nginx). [Side-note: I have no idea which webserver or WordPress plugin you use, so I omitted config snippets.]

    2. If this doesn’t help already, or if this is not enough, distribute the content using a reverse proxy (like Varnish). It’s easy to define your main server as the origin server and let various Varnish servers in front of it handle the rest.

    3. If Varnish is not good enough and your site can be served from a CDN entirely, have a look at someone like edgecast (speedyrails is a reseller of them). They allow you to do transparent caching:

      • http://my-blog.com is pointed to edgecast’s server directly
      • you configure edgecast to check http://mainserver.my-blog.com if no cache is filled
      • configure cache headers to avoid frequent lookups
      • they also allow you to purge the cache (for when you update your blog)
    4. If all of the above is not for you, I suggest you check out Cloudflare. They do what you want to do (and more). I’m test-driving them myself, works flawlessly so far.

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

Sidebar

Related Questions

Trying to set up caching on our datasets - we're using clr stored procedures
I'm trying to do some caching using VaryByParam AND VaryByHeader. When an AJAX request
I am trying to make my web application faster by using caching of web
I am trying to implement caching using jQuery UI autocomplete. I am using jQuery
After using a caching plugin to fix numerous hotlinks, some of the generated html
How do I apply caching when using jquery treeview plugin. I need to show
I'm using ajaxSubmit plugin to send Ajax forms, but for some reason this plugin
I'm using memcache for caching (obviously) which is great. But I'm also using it
I am trying to use javax.cache.CacheManager JSR107 API using EhCache as caching solutioarin provider.
I am already using output caching in my ASP.NET MVC application. Page speed tells

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.