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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:12:20+00:00 2026-06-15T16:12:20+00:00

I have a script that is generating an image with PHP on a server,

  • 0

I have a script that is generating an image with PHP on a server, in the form of image.png. I’m then using this image in different places using <img src="http://domain.com/images/image.png" />.

The problem I’m running into is that even though the image is being regenerated every 30 minutes, it seems to be cached and won’t show the new values until I go to http://domain.com/images/image.png and then ctrl+shift+refresh.

Is there any way I can keep the image name the same, but make it always show the newest version of the image?

  • 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-15T16:12:22+00:00Added an answer on June 15, 2026 at 4:12 pm

    There are a few options, depending on your situation. If “images/image.png” is an actual file on the server and you are accessing it directly, then you have to change the cache settings on the folder or use .htaccess to inform a browser to resend it.

    <FilesMatch "\.(ico¦pdf¦flv¦jpg¦jpeg¦png¦gif¦js¦css¦swf)$">
    ExpiresDefault A604800
    Header set cache-control: "no-cache, public, must-revalidate"
    </FilesMatch> 
    

    If you are using PHP to find the image and returning it, you can use PHP to send headers.

    header("Expires: ".gmdate("D, d M Y H:i:s", time()+1800)." GMT");
    header("Cache-Control: max-age=1800");
    

    To do it perfectly with PHP, you can check if its actually modified

    $last_modified_time = @filemtime($file);
    header("Expires: ".gmdate("D, d M Y H:i:s", $last_modified_time+1800)." GMT"); 
    //change with $last_modified_time instead of time().
    //Else if you request it 29mins after it was first created, you still have to wait 30mins
    //but the image is recreated after 1 min.
    
    header("Cache-Control: max-age=1800");
    header("Vary: Accept-Encoding");
    
    // exit if not modified
    if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
        if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time) { 
            header("HTTP/1.1 304 Not Modified"); 
            return;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that is generating a MySQL select statement: select *
I have a php script that is generating an unspecified number of divs inside
I have script that reads remote file content and writes it to local server.
I have this script that run to fix my menu bar to the browser
I have an script that adds products to a remote database using a RESTful
I have a script that generates a csv file using the following code: header('Content-type:
I would like to generate a dynamic image from a script, and then have
I have a loooooong running script that us generating a clustered index on a
I have a php script which is generating a log file. On the other
Possible Duplicate: Show progress for PHP long script I have a PHP script that

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.