Invalid Cached Content, If-Modified Headers?

I had a special problem:

PHP :

// checks If-Modified-Since header (if nothing has changed)
// Sends HTTP/1.0 304 Not Modified
// Sends Cache-control: public, must-revalidate
// exits

// if NO If-Modified-Since or something has changed
// builds content
// Sends Last-Modified: [DATE TIME]
// Sends Cache-control: public, must-revalidate
// exits

I am using jQuery AJAX to try to update the content on demand, I am trying to do this by changing the If-Modified-Since header from DATE TIME in the past using the "beforeSend" parameter.

This is currently happening:

  • Request completed, 200 OK response with fresh content
  • Subsequent requests receive a response of 304, and the browser retrieves from the cache
  • CONTENT CHANGED on the server
  • The request is executed with the modified If-Modified-Since header (without changing the URL string), the response is 200 OK with fresh content
  • Subsequent requests (without changing the If-Modified-Since header) seem to return the old content from step # 1

I assume that it seems to them that in step 4 the contents of the browsers should be updated, what am I missing?

, , : http://tweetplenty.com/test/test2.php... FF firebug, im console.log()... :

, : http://tweetplenty.com/test/test.zip

+2
3

, . № 2 .

+1

jquery script PHP . . ( -, )

-, AJAX ?

0

XmlHttpRequest script , .

, script

mydomain.com/myscript.php 

let say Jquery Ajax -

mydomain.com/myscript.php?t=[some_value].

[t] .

In other words, try creating a unique URL every time you submit a request through an XMLHttpRequest object.

As for the Cache-Control header, there are a few more options that you should pay attention to.

Hello,

0
source

Source: https://habr.com/ru/post/1715565/


All Articles