0

I have a web page with a list of items and a form to add new items, and when you add an item, it updates the list.

Now the problem is when you add an item, it takes several minutes before the list on the page is updated, the item is inserted into the database correctly, and if I do the sql statement directly on the database, it returns the correct number of items.

Now the reason I am sure the data is cached somewhere, is that I got another page when I can see the list, and if I refresh it right after I add an item it shows correctly, and if I wait some time and refresh it shows correct again.

Also I have tried adding SQL_NO_CACHE to the query, but it did not change anything.

EDIT Forgot to mention I am doing the request with AJAX if it makes any difference.

I just tried to open the page in a different browser and it loads the same page, to clarify if I add an item i chrome, the new item does not show up in the list in Firefox.

Also I timed it takes close to 5 minutes flat for the page to show the correct list.

4

2 に答える 2

0

Webページをキャッシュしないようにブラウザに指示していますか?

これをリストページの上部に配置します。ヘッダーは、レンダリングされたHTMLをキャッシュせず、常に最新の情報を要求するようにブラウザーに指示します。

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

http://php.net/manual/en/function.header.php

于 2012-12-03T21:58:28.527 に答える
0

私は問題を発見しました.私のウェブホストは、読み込みを高速化するためにページをキャッシュするライトスピードと呼ばれるものを使用しています.

于 2012-12-14T11:34:31.917 に答える