troubleshooting Question

PHP: Clearing Cache in my PHP pages?

Avatar of curiouswebster
curiouswebsterFlag for United States of America asked on
Web DevelopmentPHPWeb BrowsersScripting LanguagesSystem Programming
5 Comments1 Solution19 ViewsLast Modified:
I need to add the following Perl logic to the start of my PHP file. But, my attempt failed.

    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;

Can someone show me how this should look in PHP?


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros