How server-side integration works
In a client-side architecture the path is: server → HTML with no recommendations → browser → JS
snippet → personalization API → recommendations rendered. That is two sequential round trips, and
the visitor sees the flicker of an empty block filling in.
In a server-side architecture:
1. Browser request → the store's server
2. Server → the personalization API (in parallel with other data)
3. Server receives recommendations and renders them into the template
4. Finished HTML page → browser
The visitor sees recommendations on load, with no delay and no shift.
Architectural patterns
A synchronous call
# Pseudocode: a synchronous call while rendering the page
def render_pdp(product_id, user_id):
product = db.get_product(product_id)
try:
recommendations = personalization_api.get_recommendations(
user_id=user_id,
context={"product_id": product_id},
timeout=200 # ms — a hard timeout
)
except TimeoutError:
recommendations = bestsellers_cache.get() # fallback
return render_template("pdp.html",
product=product,
recommendations=recommendations)
Parallel calls
For pages with several recommendation blocks, the API calls run in parallel:
with ThreadPoolExecutor() as executor:
future_similar = executor.submit(api.similar_items, product_id)
future_bought_together = executor.submit(api.bought_together, product_id)
similar = future_similar.result(timeout=0.2)
bought_together = future_bought_together.result(timeout=0.2)
Caching responses
| Content type | Recommended TTL |
|---|---|
| Bestsellers and trends | 15–60 minutes |
| Recommendations for anonymous visitors | 5–15 minutes |
| Personal recommendations (signed in) | 1–5 minutes |
Server-level caching reduces load on the API and removes the risk of degradation at peak traffic.
When to choose server-side
- SEO matters — the recommendation blocks need to be indexable
- A headless or API-first architecture — there is no single JS context
- High traffic — predictable performance is needed, independent of browser speed
- No layout shift — which matters for Core Web Vitals and for the experience
Tip: a hybrid is often the sensible first step: critical blocks — the homepage carousel,
product page recommendations — server-side, and secondary ones such as popups and banners
client-side. It reduces the development scope of a first integration.