plainblack.com
Username Password
search
Bookmark and Share
Subscribe

Random Asset Proxy Macro

^RandomAssetProxy();
^RandomAssetProxy(Asset URL);
This macro works similarly to the ^AssetProxy(); macro except instead of displaying the Asset, it picks a random Asset from the descendants of the Asset whose URL is supplied as the argument.

This Macro may not be nested inside other Macros.

 

NOTE: The behavior of this macro will be different depending on whether the site viewer is a visitor or a logged in user!

If you are logged in, each time you reload the page you will see a new random asset; but if you are a visitor, reloading the page will result in the same (cached) content unless you clear out your browser cache.

This may be acceptable behavior for your site, as it will help reduce the number of requests WebGUI has to process (and perhaps give users a motive for logging in). However, it is one more thing to keep in mind when trying to troubleshoot problems reported by site visitors.

 

Explanation:

If you are a logged in user, WebGUI's HTTP headers are configured to always present you with the latest content (Cache-Control: no-cache); as such, if you reload the page, your browser should always request new content. WebGUI will re-generate the page with a new random asset in place.

If you are not logged in, WebGUI sends different HTTP headers, including: "Cache-Control: must-revalidate, max-age=1". The implication of this is that when your browser attempts to re-load the page (i.e., you hit the refresh button), it sends a GET request with an "If-Modified-Since:" clause. As long as the page (or assets on the page) have not changed, WebGUI returns a "304 Content Not Modified" response, permitting your browser to display the locally cached content instead. The page will not actually re-load, even if you hit ctrl+F5.

It appears that when WebGUI is calculating the last-modified date of a page, in order to determine whether to send a "304 Content Not Modified" response or not, it only looks at the last-modified date of assets on the page. The presence of the RandomAssetProxy macro does not come into play in the calculation.

(These notes are based on observations of WebGUI's behavior, version 7.5, via the Firefox Live HTTP headers add-on, and not inspection of WebGUI's API itself. Programmers more familiar with the code are welcome to add/edit as necessary.)

Keywords: http header macro randomassetproxy

0preaction: "You can bypass the cache problem by using WebGUI's built-in advertisement features. They are designed to bypass WebGUI's caching."
0aewhale: "Do you have a link to the BuiltIn advertising features?"
0Trex: "aewhale, preaction is referring to WebGUI's AdSpace feature (http://www.webgui.org/user-guides/webgui-administrators-guide/webgui-administrators-guide/advertising) Unfortunately, Ad Spaces are not templated and give you no control over HTML output, so they are only a partial solution. (See the following RFE: http://www.webgui.org/rfe/request-for-enhancement/9057) AdSpace will only place text, images or embedded multimedia, so it's not possible to use this to place randomly-selected article assets, for example, on the page."
Search | Most Popular | Recent Changes | Wiki Home
© 2018 Plain Black Corporation | All Rights Reserved