0

I am doing a webpage for my band right now, and I have a problem with appending html files.

I have an index file with basic content which is more like a template. For example the news are stored in a seperate html file and I used jQuery's .append do "bind" them into the space where I want it to be.

The news.html changes quite often, and the problem is: The user does not see any changes, because it's still stored in the cache. I tried things like

<meta http-equiv="expires" content="0">

and

<meta http-equiv="Cache-Control" content="no-cache" />

for both, the index and the news HTML, but it did not work. I assume it's because of the .append. Is there a way, to tell the append function, that it should always load the .html from server?

Greetings capekall

capekall
  • 107
  • 8

1 Answers1

1

How are you loading the news.html? With $.ajax? Then you can pass a parameter to specify that it should not be added to the cache (see the cache-property in the settings):

http://api.jquery.com/jquery.ajax/

The default value is true, which means the page IS added to the cache.

You need to do something like:

$.ajax("/news.html", {cache: false});
PzYon
  • 2,833
  • 2
  • 14
  • 26
  • I'm doing that via `$.get("news.htm", function(result) { $("#news").append(result) });` – capekall Oct 15 '14 at 17:29
  • Ok, $.get basically wraps $.ajax. So what you could do is use $.ajax directly so you can specify the cache parameter: `$.ajax("news.htm", {cache: false, success: function(result) { $("#news").append(result) });` – PzYon Oct 15 '14 at 17:33