Saturday, 15 September 2012

php - Javascript Widget and server cache issue -



php - Javascript Widget and server cache issue -

i built magento , wordpress module displays popup. user preferences (such if user seen particular popup, how many times, etc.) stored within single cookie array using serialize function. module inserts page head javascript.

<script type="text/javascript" src="http://www.thesamepageurl.com/js/modulescript.js"></script>

modulescript.js makes ajax phone call php script within same site , appends response html body. php script checks user cookie , depends on cookie value prints different popup content response different every time.

the issue in cases entire html cached on server side (using varnish cache or other service). not sure why, ajax phone call response cached , hence showed popup users closed or never showed popup because when user closed don't show 1 time again cached. prevent added dummy post parameter. when post method used, not cached more.

jquery.ajax({ type: "post", url: urlaction, data:'justsomething=1', success: function(response){ jquery("body").append(response); } });

question: safe way, using post ajax request within javascript prevent entire page cached (the page javascript located) or prevent caching url called ajax? don't want prevent entire site cached.

php ajax caching varnish

No comments:

Post a Comment