Support » Plugin: Amazon Product in a Post Plugin » Cache Ahead

  • Resolved jrcollins

    (@jrcollins)


    Hi, could you please explain how the “cache ahead” option works?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter jrcollins

    (@jrcollins)

    Most of my posts have only 1 product but I do have a few list type posts with a maximum of 5 products on the page. Is that too many products to have on one page and what are the best settings to reduce the risk of getting throttled?

    • This reply was modified 1 year ago by jrcollins.
    • This reply was modified 1 year ago by jrcollins.

    I wonder the answer too. Meeting frequently with request throttling.

    Thread Starter jrcollins

    (@jrcollins)

    Almost 2 months and still no answer.

    • This reply was modified 10 months, 3 weeks ago by jrcollins.

    Hi @jrcollins & @izreview,
    I am the original creator of the plugin – from 2009 through earlier this year. Let me see if I can explain it to you (it can get a bit complicated because of the Amazon API throttling issues).

    The Cache Ahead option has two functions:

    1. For pages and single posts & single post type posts, it looks at all the products on the page and combines the calls into blocks of 10 products per API call.
    2. On list lages (i.e., the posts page), it looks at all the products in the page query and combines the calls into blocks of 10 products per API call.

    Keep in mind that the number of products that will be fine on a page, depends on several factors. The more products you have, the longer the API will take to return data and be processed by the plugin. The server resources are another factor – if you are running on a slower server with not as much memory, more products will cause a longer page load (but really only when the plugin has to make calls to the API calls because the cache has expired). The best suggestion I can give on this, is to try things out and see what happens and see if things slow down at all.

    There is not really any “limit” to the number of products you can have on a page, as far as the plugin is concerned. It just comes down to what works best for you. But I do suggest that you use the “Cache Ahead” Option if you can, and also set the Cache Time to a higher number (3600 is default which is one hour, I recommend 3-4 hours – so 14400 for 3 hours or 18000 for 5 hours.) This will reduce the number and frequency of the API calls to Amazon and will generally speed things up.

    With that said, Amazon does throttle API calls very quickly, so if you have a lot of products and it starts doing multiple calls in a row to get those products into cache, you might hit your throttle limit on one page load. In that case, you would want to turn off the cache ahead feature. Whether you should use it or not really depends on your API standing with Amazon, though. If you sell a lot of products and have a lot of calls you can use, you are less likely to be throttled while using the Cache Ahead feature. If you are just starting out, you may not be able use it if you have too many products because it will get you throttled from the sheer number of calls you are making to the API in succession.

    I hope this helps explain it a little better. And sorry for the long delay in response – I don’t usually respond to the support threads anymore – I just happened to see this one and have the knowledge to respond.

    Best Regards,
    Don

    Thread Starter jrcollins

    (@jrcollins)

    Hi @prophecy2040, thanks for responding. That helped clarify things but I still have a couple of questions.

    I don’t quite understand what you said about the 2 functions. For list pages, do you mean blog/category pages?

    If there are too many products on the page wouldn’t turning off the cache ahead function make the problem even worse?

    Hi @jrcollins,
    No problem – I can elaborate a bit. I was trying not to write a novel yesterday!

    Yes, the list pages are the category and archive pages. Most of the time these just show the excerpt which may or may not have the Amazon products shown (depending on your settings). With cache ahead turned on, the plugin will look through the content of the entire query for products and combine them into Amazon API calls.

    For example (we’ll call this case one), let’s say you have it set to show 10 posts on the archive/category or posts pages, it would look through all 10 posts (even if they only show excerpts) and gather the products and cache them all in groups of 10 via calls to the Amazon API (assuming the products cache expired). If you had 10 posts with 2 products each, that would equate to 2 API calls:

    10 posts times 2 products per post = 20 products divided by 10 products per API call = 2 calls to the API – which is not a big deal at all

    Now if you had 10 products per page (we’ll call this case two), it would equate to 10 x 10 = 100 = 10 API calls. 10 API calls at 1 to 2 seconds apart (to keep from getting throttled) would mean 10-20 seconds of load time to cache the products when needed. If you have a lot of API calls allowed, that may be fine, but for new affiliates you start out with a very low API call limit (per second, per minute, per hour and per day), so you may get throttled on just that one page load alone.

    In case one, you would be fine using the Cache Ahead option because all of your products would be cached at one time and you would not get throttled. If you have your cache time set high enough – you would not need to have any API calls again for some time and not get throttled.

    In case two, you would want to turn the Cache Ahead off if you are getting throttled – especially if you are a new affiliate without many sales (more sales equals more API calls allowed). With the Cache Ahead off, it will only call the API and cache the products when the single post page loads (again, depending on your settings).

    On your other question:

    If there are too many products on the page wouldn’t turning off the cache ahead function make the problem even worse?

    If it is just a page or single post/post type page we are talking about, turning off the Cache Ahead option will not have any effect, really. The page will still get checked for products and products will get cached as usual, but only for the main query for that page load. I should have elaborated a bit more on the initial explanation of the page load cache ahead version – it not only caches the page but any query that is pulled while the page is loading (i.e., sidebar items or menu items). So it does more than just Cache Ahead the main page load query. So, if you do have a lot of products on the page (and other pages), you would need to have Cache Ahead off or it might throttle you out.

    The idea of the cache ahead was implemented quite some time ago when Amazon allowed a lot more API calls (they drastically reduced them when Version 5 of the API rolled out). It worked without any need to think about the number of calls you were allowed, because you could have 100 products on a page and you would still be fine. With the reduction of calls allowed, only people with a lot of sales can really use it with with a lot of products because every one else will get throttled (myself included).

    I have found that if you keep the products down to around 5 per page/post and have your list pages set to 10 or less, you are usually fine with Cache Ahead on. Any more than that you have to test your own settings because every affiliate is different (based on sales).

    I hope this helps some.
    Warm Regards,
    Don

    Thread Starter jrcollins

    (@jrcollins)

    Hi Don, thanks for the explanation. With the cache ahead function turned off does the plugin still combine products into blocks of 10 per API call? For example, if I have a single post with 10 products on it would there be 10 separate API calls or just 1?

    @jrcollins,
    Good question. Yes, it will still group them in 10 products per call. It was decided that grouping them was the best thing to do because of the throttling issues with Amazon.

    So in summary, 10 products on a page with the Cache Ahead off would be 1 API call and not 10.

    Warmest regards,
    Don

    Thread Starter jrcollins

    (@jrcollins)

    Thanks, I appreciate your help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Cache Ahead’ is closed to new replies.