How do i hard refresh php?

How do i hard refresh php?

Get the solution ↓↓↓

I have a php file and it doesn't update the right data from the server(apache) the first time I open it. I have to do a hard refresh ( Shift + refresh ) or (ctrl + f5) for the right data to appear in the browser. After I use hard refresh, everything works perfectly and i don't have to do a hard refresh again for the data to come in. I have tried different codes from stack overflow to clear the cache, but it couldn't give me a right result. So i wanted to know if there was a PHP function to do a hard refresh the first time i open the webpage so that my webpage works smoothly.

GOAL : Hard refresh automatically when the PHP page Loads up

code that my php file has at the moment

header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0");

i have also tried


header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

2022-03-31




Source

Share


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.


Similar questions

Find the answer in similar questions on our website.

PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/

Welcome to webdevask.com

How do i hard refresh php?

Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.

Get answers to specific questions

Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.

Help Others Solve Their Issues

Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.

I am a HTML, PHP developer, but lately I am going crazy because the browser doesn't refresh the page when I make changes in the code, apparently the page is refreshed from cache and is not showing the changes. Could You fix that Please. I tried the recommendations of press Shift and the refresh button and the Control, Shift, R, key combination, but that doesn't work. Thank You Very Much.

I am a HTML, PHP developer, but lately I am going crazy because the browser doesn't refresh the page when I make changes in the code, apparently the page is refreshed from cache and is not showing the changes. Could You fix that Please. I tried the recommendations of press Shift and the refresh button and the Control, Shift, R, key combination, but that doesn't work. Thank You Very Much.

Solution choisie

I found the problem, in the php.ini file, the value for: opcache.enable has to be zero: opcache.enable=0 Thanks for your time and I hope this helps someone else.

Lire cette réponse dans son contexte 👍 0

Sorry to bring up this old thread again, but i have same problem with another site.

The site is only built with HTML.

The problem.

I have a div that i upload some picture to now and then and all new picture won't show up untill i press ctrl+f5.

This only happens with Firefox and not IE. The thing is that i run my FF with default settings, so all other users with FF should have the same problem.

What i've tried so far is



How do i hard refresh php?
[b]At all new picture[/b]

And some that i found on the web


# YEAR

  Header set Cache-Control "max-age=29030400"

# WEEK

  Header set Cache-Control "max-age=604800"

# 45 MIN

  Header set Cache-Control "max-age=2700"

# Turn on Expires and set default expires to 3 days
ExpiresActive On
ExpiresDefault A259200

# Set up caching on media files for 1 month

  ExpiresDefault A2419200
  Header append Cache-Control "public"


# Set up 2 Hour caching on commonly updated files

  ExpiresDefault A7200
  Header append Cache-Control "private, must-revalidate"


# Force no caching for dynamic files

  ExpiresDefault A0
  Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
  Header set Pragma "no-cache"

No one works. So is there any other solution?

EDIT: Just notices that this question should be posted at HTML section? Mod, or should i start a new thread?

How to force refresh page PHP?

Use header() function to refresh a web page in PHP. The HTTP functions are those functions which manipulate information sent to the client or browser by the Web server before any other output has been sent. The PHP header() function sends an HTTP header to a client or browser in raw form.

How to refresh PHP file?

Refresh a Page in PHP.
Use the header() Function to Periodically Refresh the Page in PHP..
Use the HTML meta Tag to Refresh the Page Periodically in PHP..
Use location.reload() JavaScript Function to Refresh the Page Periodically..

How do you refresh a web page automatically after a few seconds in PHP?

Answer: Use the header() Function You can simply use the header() function to automatically refresh a page periodically (i.e. at certain time intervals) using PHP. Please, note that header() function must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP script.

How do you refresh a page in HTML?

Window location.reload() The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.