2

We have a static HTML file that is updated in every 10-30 minutes (random time between the two timeframe).

We are using:

<META HTTP-EQUIV=refresh CONTENT=600>

Q: But we need to only refresh the page on client side if the HTML file is really updated. How can we do this? Can JavaScript check if the static HTML page was re-created?

UPDATE: could it help that I can create another HTML file ex.: foo.com/status.html with the following: - normally the content of it would be "0" - but if the html get's updated, for 10 seconds, the status.html file would be "1"

UPDATE#2: there is no jQuery (yet?) in the html file. Using apache2. (exactly what configs needed? )

2
  • Is there any harm in reloading if the page hasn't updated? Commented Apr 29, 2014 at 10:03
  • 1
    "Can JavaScript check if the static HTML page was re-created?" no javascript is clientside. It can not possibly know whether it was changed. You will need to do a request with a precheck to something serevr side to check whether there are changes Commented Apr 29, 2014 at 10:05

1 Answer 1

6

Well you cannot really check if HTML file is recreated without hitting server. Only thing you can do is make an AJAX call and get last modified time of file. Compare it with some stored modification date-time value and issue refresh command if it is modified after stored value.

Don't know what you are using on server side. Also if you are using jQuery it is really easy to make AJAX call with $.ajax.

Well on other hand if it is not modified shouldn't it be cached? On your server or somewhere in-between?

PS:- If you can post server side setup details we can help you better.

Sign up to request clarification or add additional context in comments.

2 Comments

+1 Yay someone paid attention! This is basically what I was going to suggest but I was distracted by stupidity.
:) old issue with developers not reading what is required but jumping to solution. But we need to know about server side setup/framework to really help here.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.