Posted by patrickwang5 on May 1, 2010 at 7:12pm
2 followers
Jump to:
| Project: | Boost |
| Version: | 6.x-1.18 |
| Component: | Core compatibility |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
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
#1
What does the "random+something" look like?
#2
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.
#3
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
#4
I run it a few times, as below in firebug,
http://www.website.com/rssdata/rssdata_json?_=1272748677913
http://www.website.com/rssdata/rssdata_json?_=1272748775171
http://www.website.com/rssdata/rssdata_json?_=1272748803525
My url location is http://www.website.com/rssdata/rssdata_json, $.ajax will use the above urls to request. thanks.
#5
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 -sRewriteRule .* 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]
#6
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.
#7
So I also need to not set the query string when a request comes in from this URL.
Replace this
<?phpfunction 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
<?phpfunction 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)));
}
...
?>
#8
#9
Great.