MyBB Community Forums

Full Version: query strings on avatars
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
(2015-10-05, 01:34 PM)Leefish Wrote: [ -> ]having the avatars show is really popular though bad for site statistics with these page testing tools. The issue is the ? in the query string isnt it? is there another way of writing that so that the advantage of the dateline is kept without the query string? The js files have the same effect with the query string.

http://www.stevesouders.com/blog/2008/08...erystring/

Yes, but since there is no hook to modify this behavior you'd have to record the date when the avatar was last updated and use that combined with the .htaccess I provided earlier. 

Another option would be to wrap this in a function inside the template and let the function remove the query string while also using the .htaccess, this would ensure that the avatar is refreshed once an hour and would ensure that the client's browser doesn't have to request for an updated version. You will have to see how this would work, its been some time since I played with the templates.
(2015-10-05, 01:14 PM)StefanT Wrote: [ -> ]The downside of removing the query string is that avatars will be cached which means that changing the avatar appears to have no effect until the browser cache is cleared.

True.

(2015-10-05, 01:34 PM)Leefish Wrote: [ -> ]having the avatars show is really popular though bad for site statistics with these page testing tools. The issue is the ? in the query string isnt it? is there another way of writing that so that the advantage of the dateline is kept without the query string? The js files have the same effect with the query string.

http://www.stevesouders.com/blog/2008/08...erystring/

One option would be to change it to be like {filename}-{timestamp}-{extension}. This may well be possible with a rewrite rule, otherwise it would need quite a few code changes.
(2015-10-05, 02:31 PM)Euan T Wrote: [ -> ]One option would be to change it to be like {filename}-{timestamp}-{extension}. This may well be possible with a rewrite rule, otherwise it would need quite a few code changes.

How is this any different to having the timestamp in the query string? As long as {timestamp}=TIME_NOW the browser is forced to make a request on every pageload. If you want the luxury of only updating the avatar when it was changed {timestamp} must be the actual timestamp when the avatar last uploaded. The htaccess with the cache headers is required so that the CDN doesn't frequently query the server for an updated version, since there is no cache header sent at all.
(2015-10-05, 02:52 PM)SentoWeb Wrote: [ -> ]If you want the luxury of only updating the avatar when it was changed {timestamp} must be the actual timestamp when the avatar last uploaded.
This is what MyBB does...
(2015-10-05, 02:58 PM)StefanT Wrote: [ -> ]
(2015-10-05, 02:52 PM)SentoWeb Wrote: [ -> ]If you want the luxury of only updating the avatar when it was changed {timestamp} must be the actual timestamp when the avatar last uploaded.
This is what MyBB does...

There is always a way to push things in the right direction. This fix should remove the query string without any core changes.

inc/config.php
Class AvatarFix {
    public function __toString() {
        global $mybb, $post;
        if ($post['avatar']) {
            $avatar = substr($post['avatar'], 0, -1);
            $avatar = substr($avatar, 0, -19);
            return $mybb->settings['bburl'].$avatar;
        } else {
            return $mybb->settings['bburl'].'/'.$mybb->settings['useravatar'];
        }
    }
}

$config['avatarfix'] = new AvatarFix;



postbit_avatar template


<div class="author_avatar"><a href="{$post['profilelink_plain']}"><img src="{$mybb->config['avatarfix']}" alt="" {$useravatar['width_height']} /></a></div>



Yes, it looks a bit dirty but this should do for now.
I thought it was safe for browsers to cache the results of a GET request (the query string is used to determine if two requests are equal).
(2015-10-05, 06:40 PM)laie_techie Wrote: [ -> ]I thought it was safe for browsers to cache the results of a GET request (the query string is used to determine if two requests are equal).

The query string changes (TIME_NOW) so the browser will send a request.

See the answer below.
(2015-10-05, 06:42 PM)SentoWeb Wrote: [ -> ]
(2015-10-05, 06:40 PM)laie_techie Wrote: [ -> ]I thought it was safe for browsers to cache the results of a GET request (the query string is used to determine if two requests are equal).

The query string changes (TIME_NOW) so the browser will send a request.

No, it doesn't. The query string is the time the avatar was uploaded. It changes whenever you change your avatar. The problem Andrew is trying to solve is that some CDN/proxy systems won't proxy ANY content with query strings and Google Pagespeed shows false positives for resources with query strings.
(2015-10-05, 06:47 PM)Euan T Wrote: [ -> ]
(2015-10-05, 06:42 PM)SentoWeb Wrote: [ -> ]
(2015-10-05, 06:40 PM)laie_techie Wrote: [ -> ]I thought it was safe for browsers to cache the results of a GET request (the query string is used to determine if two requests are equal).

The query string changes (TIME_NOW) so the browser will send a request.

No, it doesn't. The query string is the time the avatar was uploaded. It changes whenever you change your avatar. The problem Andrew is trying to solve is that some CDN/proxy systems won't proxy ANY content with query strings and Google Pagespeed shows false positives for resources with query strings.

My bad, I misunderstood the code because I was looking at some mybb source code at the same time. My solution above is still valid.
(2015-10-05, 06:47 PM)Euan T Wrote: [ -> ]
(2015-10-05, 06:42 PM)SentoWeb Wrote: [ -> ]
(2015-10-05, 06:40 PM)laie_techie Wrote: [ -> ]I thought it was safe for browsers to cache the results of a GET request (the query string is used to determine if two requests are equal).

The query string changes (TIME_NOW) so the browser will send a request.

No, it doesn't. The query string is the time the avatar was uploaded. It changes whenever you change your avatar. The problem Andrew is trying to solve is that some CDN/proxy systems won't proxy ANY content with query strings and Google Pagespeed shows false positives for resources with query strings.

that's the exact problem I'm running into.
Pages: 1 2 3 4 5