Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag 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

 
SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curiouswebster

ASKER

So, I should insert those 5 headers at the start of each PHP file? Also, I will be on EST. Should I preserve "GMT"?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial