PDA

View Full Version : [PATCH] Prevent status frame from reloading all images



mcfly
2005-05-23, 15:24
Hello all,

For the Default skin, auto-refreshing the status frame causes the browser (at
least Firefox 1.x) to reload all images in the status page. This has the odd
visual effect that the images are invisible for a short time and then get
redisplayed. I did some sniffing with ethereal and saw that the browser sends
Pragma/Cache-Control: no-cache headers if the page is reloaded using the
"refresh" http-equiv meta-tag even for images within a page.

The patch below replaces the reload mechanism with a javascript version that
does not cause the browser to reload all images (It will do a GET for each image
(but without the no-cache header) and the server answers with 304 (Not modified).

Slightly tested with Firefox 1.04 (MacOSX), Slimserver (SVN trunk) running on
Debian SID.

Rants/Comments?

Index: status_header.html
================================================== =================
--- status_header.html (revision 3281)
+++ status_header.html (working copy)
@@ -2,13 +2,25 @@
<head>
<title>[% "SQUEEZEBOX_MUSIC_PLAYER" | string %] [% IF player_name %][% player_name | html %][% END %]</title>
<meta http-equiv="Content-Type" content="text/html; charset=[% LOCALE %]">
- <meta http-equiv="refresh" content="[% refresh %]; url=status_header.html?player=[% player | uri %]&amp;start=[% start %]&amp;refresh=1">
<style type="text/css"> <!--
[% INSERT slimserver.css %]
--> </style>
<script language="JavaScript">
<!-- Start Hiding the Script

+function doLoad()
+{
+ setTimeout( "refresh()", [% refresh %]*1000);
+ if (parent.playlist.location != '') {
+ parent.playlist.location.reload(false);
+ }
+}
+
+function refresh()
+{
+ window.location.reload(false);
+}
+
function switchPlayer(player_List){
var player = player_List.options[player_List.selectedIndex].value;
parent.location.href = "[% webroot %]index.html?player=" + player;
@@ -17,7 +29,7 @@
// Stop Hiding script --->
</script>
</head>
-<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="if (parent.playlist.location != '') parent.playlist.location.reload(true);">
+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="doLoad();">
<table width="100%" cellspacing="0">
<tr height="32">
<td width="4" class="darkgrey"></td>

Ben Sandee
2005-05-23, 16:02
> The patch below replaces the reload mechanism with a javascript version that
> does not cause the browser to reload all images (It will do a GET for each image
> (but without the no-cache header) and the server answers with 304 (Not modified).

I applied the patch manually because I couldn't get a good copy of the
patch data out of the email. I'm pretty sure I did it correctly.
Anyway, after applying the patch things seem to work fine but as soon
as the right pane reloads the track restarts which means I get about
30 seconds and then the song restarts.

You don't see the same behavior?

Ben