views:

22

answers:

1

Hey, I got a static page which uses an XSLT stylesheet and pulls in the overall menu from a separate menu.xml.

Usually, the menu wont change, neither will the stylesheet. However, at some point they may, because the content is modified. In any case, the auxiliary styling files are not reloaded when you reload the main page.

Essentially, my question is: how do I get the browser to update the additional files when they change (I could live with it reloading it all the time, but it would be better if there was a way to have it pulled in only when it actually changes)?

I pull the stylesheet in with

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="main.xslt" type="text/xsl"?>
<foo>
  <bar />
</foo>

Edit: On a side node, if I explicitly open the stylesheet or the menu-file in the browser, an then reload the main page, it updates correctly, but obviously, that is not an option.

+1  A: 

You might want to serve the modification time of your style files using the Last-Modified HTTP header.

Frédéric Hamidi
It crossed my mind, but how is the client supposed to know the Last-Modified time is *newer* than his version without fetching it? And - can I set the header without scripting (i.e. php et.al.)?
bitmask
The client is supposed to check if the `Last-Modified` time is newer than the modification time of the version in its cache. If it is, it fetches the object again.
Frédéric Hamidi
Didn't know that. Thanks.
bitmask