Avatar of curiouswebster
curiouswebster
Flag for United States of America

asked on 

PHP: Clearing Cache in my PHP pages?

I need to add the following Perl logic to the start of my PHP file. But, my attempt failed.

Perl:
    push(@headers, "Expires: Mon, 01 Jan 1970 00:00:00 GMT\n");
    push(@headers, "Date: $now\n");
    push(@headers, "Last-modified: $now\n");
    push(@headers, "Pragma: no-cache\n");
    push(@headers, "Cache-control: private no-cache no-store must-revalidate max-age=0 pre-check=0 post-check=0\n");
    #push(@headers, "Server: $ENV{SERVER_NAME} + $ENV{REQUEST_URI}\n");
    push(@headers, "Status: $code\n");
    push(@headers, "Content-Type: text/html\n");
    push(@headers, "Location: $new\n") if $new;
    push(@headers, "\n");

PHP (Failed):

    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Date: $now\n");
    header("Last-modified: $now\n");
    header("Pragma: no-cache\n");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    header("Status: $code\n");
    header("Content-Type: text/html\n");
    header("Location: $new\n") //if $new;
    header("\n");

Can someone show me how this should look in PHP?

Thanks

 
System ProgrammingWeb DevelopmentPHPWeb BrowsersScripting Languages

Avatar of undefined
Last Comment
Yujin Boby

8/22/2022 - Mon