Tuesday 15 May 2012

php - Weird behavior when using custom HTTP header -



php - Weird behavior when using custom HTTP header -

my website uses ajax load pages div , sends next custom header each ajax request: x-ajaxrequest.

if header nowadays website sends body without header , footer, otherwise sends whole page.

this php code:

if ( !empty($_server['http_x_ajaxrequest'])) { echo($head); echo($body); echo($scripts); } else{ include("master.php"); }

now, problem is, when visits x, clicks on y's link y click's on x, x loaded header , footer if header doesn't exist. peculiar-er when developer tools (f12) open doesn't happen!

i think might caching, because ie11 (the browser developing with) has back navigation caching, then, why caching obliterate header??

here's link site that's having problems

it seems indeed caching that's causing trouble. 1 time user has visited x, browser caches (based on whatever caching rules in has , server provided). when go y , effort load x via ajax, browser knows has x in cache , delivers there (never sending request server @ all).

in chrome, default, caching turned off when open developer tools (f12) why not seeing problem when have them on. can go developer tools settings (upper right corner) , untick "disable cache (while devtools open)". should able see browser fetch x cache on page y.

one simple way solve attach parameter url (something "ajax=true" illustration ajax calls), way browser treat x , x?ajax=true 2 separate "resources" , cache 2 different versions of them.

php html ajax http http-headers

No comments:

Post a Comment