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

  • Home
  • SEARCH
  • 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 7522451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:31:35+00:00 2026-05-30T02:31:35+00:00

Here is a link to an example bandwidth throttling PHP script for a file.

  • 0

Here is a link to an example bandwidth throttling PHP script for a file. I see an improvement I can make that’s unrelated that I’ll make myself later, but other than that… How could you use this script to make another script that returns an image with throttled bandwidth, but caches the images forever? The image will never change.

  • 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-30T02:31:36+00:00Added an answer on May 30, 2026 at 2:31 am

    I think all you were asking was to modify that script to work with an image and cache the content. This should do it, pending any minor errors I may have:

    <?php
    
    $file = "yourimage.jpg"; // file to be send to the client
    $speed = 8.5; // 8,5 kb/s download rate limit
    
    // if $file is coming from get, I would use this to prevent against a nullbyte attack:
    $file = str_replace(chr(0), '', $file);
    
    if (file_exists($file) && is_file($file)) {
        header("Expires: ".gmdate('D, d M Y H:i:s', time()+3600*24*3000).'GMT'); // expires in 3000 days. 
        header("Pragma: cache");
        header("Content-Type: image/jpeg"); // needs to be changed for the file type.
        header("Content-Length: ".filesize($file));
        header("Cache-Control: max-age=" . 3600*24*3000);
    
        flush();
    
        $fd = fopen($file, "r");
        while(!feof($fd)) {
             echo fread($fd, round($speed*1024));
            flush();
            sleep(1);
        }
        fclose ($fd);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The link example is here: http://jsfiddle.net/fxr5p/ How to make if value is empty, onload
The example to demonstrate the issue can be found here: link text The test
here is link to an example: http://techchorus.net/demos/jquery/hiding-input-elements-in-a-div.html It actally disables few elements on click
I'm learning by reading this tutorial: Link Here's the code: <?php require_once 'Zend/Loader.php'; class
Here is a link to the tutorial that I am referring to. This seems
I have done this Example for implementation of the WebView. here is the link
Here is a link my example of the misaligned table rows Click preview in
I am trying to build the mvc-showcase example available here link . But i
I'm trying out the example Hello World from this link here: http://www.mulesoft.org/documentation/display/MULE2INTRO/Quick+Start I have
Need something simulat jcrop plucgin (link to example is here: http://publikz.com/one-more-task-rounded-selection-in-jquery/ ) but with

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.