I enable boost json cache and it works great. But some browsers(ie6 i know at least) cache it in the browser cache when the user request the same json 3 or 4 time so on. If the browser loads its browser cache json, it will not request the server and JQuery.ajax will not come to success. I add 'cache:false' in jQuery.ajax setting, jQuery.ajax will send your url+random+something to your server. Boost will not send back a cache copy. Any help?

Comments

mikeytown2’s picture

What does the "random+something" look like?

patrickwang5’s picture

Title: Ignore query string for a specific path » some ajax json may not cache

Below is my javascript snip:
dataUrl = "/?q=rssdata/rssdata_json";
$.ajax({
type: "GET",
url: dataUrl,
cache: false,
dataType: "json",
//data: "name=" + encodeURI(name),
success: function( catRssArray ){....} );

I check the firebug, it looks like:
get..... http://www.website.com/rssdata/rssdata_json?_=1272747236876

If I close IE and reopen it, the cache copy will not use.

mikeytown2’s picture

I need more details then what you gave me. I'm thinking about "rewriting the query string" to remove the random part. right now it appears the key to the random value is "_", is the correct???
http://wiki.apache.org/httpd/RewriteQueryString
http://www.webmasterworld.com/forum92/3580.htm

patrickwang5’s picture

mikeytown2’s picture

So http://www.kaixinurls.com/rssdata/rssdata_json is the same as http://www.kaixinurls.com/rssdata/rssdata_json?_=1272748677913 correct?

Try adding this to the bottom of your boost rules

  RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}/rssdata/rssdata_json_\.json -s
  RewriteRule .* cache/normal/%{SERVER_NAME}/rssdata/rssdata_json_\.json [L,T=text/javascript]

And incrementing the skip by 1 RewriteRule .* - [S=8]

  RewriteCond %{REQUEST_METHOD} !^GET$ [OR]
  RewriteCond %{REQUEST_URI} (^(admin|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{HTTPS} on
  RewriteRule .* - [S=7]

To this

  RewriteCond %{REQUEST_METHOD} !^GET$ [OR]
  RewriteCond %{REQUEST_URI} (^(admin|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{HTTPS} on
  RewriteRule .* - [S=8]
patrickwang5’s picture

In my cache/normal/.../rssdata folder, each url request will create a boost copy and gzip copy(there will many copies when it grows),
rssdata_json__=1272748677913.json
rssdata_json__=1272748775171.json
rssdata/rssdata_json__=1272748803525.json
rssdata_json__=1272748677913.json.gz
rssdata_json__=1272748775171.json.gz
rssdata/rssdata_json__=1272748803525.json.gz

So each time $.ajax send a request, boost will make a cache copy. what we expect is one rssdata_json cache and it serve all 'rssdata_json?_=num' requests. possible ? :) Because at the beginning, $.ajax will send 'rssdata_json?_=1272748677913' like request, there is no 'rssdata_json' cache copy.

For php, http://www.website.com/rssdata/rssdata_json is the same as http://www.website.com/rssdata/rssdata_json?_=1272748677913. But I don't know for boost cache. I will test around with your last reply boost rules.

mikeytown2’s picture

So I also need to not set the query string when a request comes in from this URL.

Replace this

function boost_init() {
...
  // Make the proper filename for our query
  $GLOBALS['_boost_query'] = BOOST_CHAR;
  $query = array();
  foreach ($_GET as $key => $val) {
    if ($key != 'q' && $key != 'destination') {
      $query[$key] = $val;
    }
  }
  $GLOBALS['_boost_query'] .= str_replace('&', '&', urldecode(http_build_query($query)));
...

with this

function boost_init() {
...
  // Make the proper filename for our query
  $GLOBALS['_boost_query'] = BOOST_CHAR;
  $query = array();
  foreach ($_GET as $key => $val) {
    if ($key != 'q' && $key != 'destination') {
      $query[$key] = $val;
    }
  }
  $args = arg();
  if ($args[0] == 'rssdata' && $args[1] == 'rssdata_json') {
    $GLOBALS['_boost_query'] = BOOST_CHAR;
  }
  else {
    $GLOBALS['_boost_query'] .= str_replace('&', '&', urldecode(http_build_query($query)));
  }
...
mikeytown2’s picture

Title: some ajax json may not cache » Ignore query string for a specific path
patrickwang5’s picture

Great.