Topic: disable XML caching to keep galleries fresh?

In this thread http://www.simpleviewer.net/forum/viewt … p?id=14080 I found:

Steven Speirs wrote:

In order to prevent the gallery's XML file being cached, use the following line in your embedding code before the fo.write("flashcontent"); line:

fo.addVariable("xmlDataPath", "gallery.xml?nocache="+new Date().getTime());

Three questions:
1. will this absolutely make it so that a gallery's content is fresh for each visit?
2. if I'm using simpleviewer galleries within svmanager, does that line just go into the svmaster/index.php?
3. do I have to do anything besides adding the line to apply the change to pre-existing galleries within the svmanager folder?

I'm currently using svManager version 1.7.8, build 110516
Thanks!

Re: disable XML caching to keep galleries fresh?

1. will this absolutely make it so that a gallery's content is fresh for each visit?

Yes, as the code adds the time (which will be different each time the gallery is viewed) as a query string to the XML file's URL. The gallery will see this as a different file each time the gallery is viewed and will reload it from the web server.

2. if I'm using simpleviewer galleries within svmanager, does that line just go into the svmaster/index.php?

There is no need to inset the code as svManager already has a similar procedure in place. Rather than adding the time as a query string, svManager adds a random number (on line 40 of 'svmaster/index.php'):

fo.addVariable("xmlDataPath", "gallery.xml?nocache=<?php echo rand(); ?>");

3. do I have to do anything besides adding the line to apply the change to pre-existing galleries within the svmanager folder?

All SimpleViewer v1 galleries created with svManager will have this 'nocache' functionality.
However, if you have imported any galleries which were created by another method, then you will need to modify each gallery's embedding code. The line of code defining the 'xmlDataPath' is the only line which needs to be modified.

Steven Speirs
SimpleViewer Support Team.

Re: disable XML caching to keep galleries fresh?

Hi Steven,
Thanks for the quick reply.  I must be missing something though.  I posted about this because presently if I change a gallery (e.g. add an image, delete an image) I don't see a change until I clear the temp files out of my browser cache.  I don't think I've done an upgrade, so iirc these galleries were all made with svManager version 1.7.8, build 110516 (tho the first one was created with sv-builder pro I guess.
I was hoping that if I changed something about XML caching, I could avoid the cache clearing dance and see gallery changes as they happen.  What do you think I should do?

here is an example gallery: http://borderlandsbestgear.com/svmanager/g1/

Once you see it, I will delete 3 images if you want, and next time you look at the gallery, I bet you'll still see them.

Thanks,
Brian

P.S. I'm considering using Juicebox + flickr for another site but it would have to be updated on a per visit basis, like I'm trying to do here, or else it won't work : (

Re: disable XML caching to keep galleries fresh?

Perhaps the random number is being generated once on first loading the page and the problem is that the browser is caching the 'index.php' file (and not regenerating the random number each time).
Try replacing:

fo.addVariable("xmlDataPath", "gallery.xml?nocache=<?php echo rand(); ?>");

... with:

fo.addVariable("xmlDataPath", "gallery.xml?nocache="+new Date().getTime());

... to see if it makes a difference.

Steven Speirs
SimpleViewer Support Team.

Re: disable XML caching to keep galleries fresh?

^in svmaster/index.php?

and then changes should be fairly immediate?  or do I have to rebuild a gallery or somesuch?

Re: disable XML caching to keep galleries fresh?

Just try it in a single gallery's 'index.php' file first to see if it works.
Try it in: http://borderlandsbestgear.com/svmanager/g1/index.php
Then edit and re-upload the gallery's XML file making a change that you would notice: http://borderlandsbestgear.com/svmanager/g1/gallery.xml
Then reload the gallery's index page to see if you notice the difference: http://borderlandsbestgear.com/svmanager/g1/index.php

Steven Speirs
SimpleViewer Support Team.

Re: disable XML caching to keep galleries fresh?

The above gallery is a SimpleViewer v2 gallery so you would need to use the following code:

flashvars.galleryURL = "gallery.xml?nocache="+new Date().getTime();

Also, you could try adding the following code to the <head> section of the gallery's 'index.php' file.

<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
Steven Speirs
SimpleViewer Support Team.

Re: disable XML caching to keep galleries fresh?

Steven Speirs wrote:

The above gallery is a SimpleViewer v2 gallery...

k thanks I will try it soon - sorry about posting in the wrong forum - I was going of the svmanager version instead of simpleviewer's tongue

Re: disable XML caching to keep galleries fresh?

I made both changes you mentioned in post 7 and on IE8 it works.  If I delete a gallery image in svmanager and refresh the page then it's gone.  It seems like having the gallery open in multiple windows can interfere and make a deleted image show up as an X, but then if you close IE and open it, the changes are applied.  so IE looks good.

On Chrome though, refreshing doesn't show changes, and closing all Chrome windows seemed to have worked one time, but I can't make it work again.  Seems like only clearing browsing data with the top 4 check boxes checked shows the changes

Chrome is pretty important.  Where might I go from here?

P.S. I don't NEED it to work w/ simpleviewer 2.x,  but if you can confirm that it'll work with Juicebox in Chrome, I can get that.

Last edited by brasmasus (2012-06-14 17:03:34)

Re: disable XML caching to keep galleries fresh?

I don't NEED it to work w/ simpleviewer 2.x,  but if you can confirm that it'll work with Juicebox in Chrome, I can get that.

I've just done a quick test with Juicebox and Chrome.

(1) Uploaded sample 'web' gallery from Juicebox-Pro download zip package (no modifications)
(2) Opened gallery in Chrome 19 on Windows 7 SP1 x64 PC
(3) Edited 'config.xml' file and uploaded it replacing previous version
(4) Went back to Chrome 19 (same session, window had not been closed)
(5) Hit F5 to refresh page, new 'config.xml' file was used and new gallery layout was displayed

All default settings were used within Chrome 19 and no 'prevent caching' methods were required within the Juicebox gallery.

Steven Speirs
SimpleViewer Support Team.

Re: disable XML caching to keep galleries fresh?

thanks Steven.

Steven Speirs wrote:

(3) Edited 'config.xml' file and uploaded it replacing previous version

This is equivalent to altering a gallery with svmanager, correct?  And it won't make any difference if the gallery is pulling linked pictures from flickr?

Re: disable XML caching to keep galleries fresh?

This is equivalent to altering a gallery with svmanager, correct?

Yes.

And it won't make any difference if the gallery is pulling linked pictures from flickr?

It does not seem to. I have just run another test.

(1) Created and uploaded a Flickr-based Juicebox-Pro gallery
(2) Opened gallery in Chrome 19 on Windows 7 SP1 x64 PC
(3) Logged into Flickr and changed the title of an image
(4) Went back to Chrome 19 (same session, window had not been closed)
(5) Hit F5 to refresh page, new image title was displayed

Again, all default settings were used within Chrome 19 and no 'prevent caching' methods were required within the Juicebox gallery.

Steven Speirs
SimpleViewer Support Team.

Re: disable XML caching to keep galleries fresh?

k great thanks for all your help!