In a comment on my post 42: Retooling Slashdot with Web Standards: A List Apart, Rene asks
Q: I'm doing a site using Amazon web services at http://zoomazon.com - I get the xml and xsl but I don't get the "caching" of the xml results that Amazon requires - any ideas? Thanks.
So far as I can see from Amazon has a number restrictions in it's license that may require caching.
A2 No more than 1 request per second (Condition A2)
D2 You must refresh all data you cache from Amazon every 24 hours except
D3 You must refresh any prices you show at least once per hour
If you expect your volumes to be low enough to not break condition A2 then you do not HAVE to cache. But for example if your page requires 2 api calls to get it's content and you expect to ever serve more than 1 page every 2 seconds then in theory you MUST cache the results from Amazon. However, even if your volumes do not require you to cache then possibly you should cache anyway as
a) Hopefully volumes will increase over time (and amazon could change the limits)
b) Your sites performance is likely to be poor if you have to make API calls to fill each page.
After a quick glance at zoomazon it looks as if the pages are all fully dynamically pulled in from Amazon as required, it would therefore be quite easy to break the API limit. On the other hand caching these would also be quite easy if you can do some server side coding.
Essentially you would need to have a store, the index would be the url of the request to Amazon. Whenever you are about to make an amazon call you first check if the result of that url is already in your store, if it is and is recent enough to use you don't make the call and simply re-serve you existing copy. If you don't have a copy or the copy is too old (more than 1 hour old if includes price, otherwise more than 24 hours) then you make the call, store the result and then use it.
Most likely the store for these results could be in memory (particularly if you have a background process to remove results that are too old from the store).
At present it looks like your site does not have any serverside coding, that is working well and obviously makes building a site simple. But if Amazon do intend to enforce the restrictions in the license it will not scale very far. OTOH getting this to work serverside would be relatively easy.
Recent Comments