Expand my Community achievements bar.

SOLVED

Request object is cached in dispatcher

Avatar

Level 2

Hi Team,

 

We have a requirement to separate mobile and desktop code, we we are using user-agent to get the device details from the backend and using that conditionally in sightly to render the device specific code.

useragent = request.getHeader("User-Agent");

We can get the device details correctly.

In author its working as expected, when we open the page in desktop  - its giving the device type as desktop, if we inspect the page and change the device as mobile in emulator and refresh the page - its showing as mobile.

 

But in the dispatcher, when we open the page in desktop  - its giving the device type as desktop, but if we inspect the page and change the device as mobile in emulator and refresh the page - its still showing as desktop only. If we navigate to any other page, then its showing as mobile.

And then when we switch to desktop and refresh the page, it still shows as mobile for that page - when we navigate to any other page, then it shows as desktop.

 

When we open any page, that particular request is getting cached, so even when we switch to any other device in emulator and refresh the page, the same request is being served.

 

@Vijayalakshmi_S  @arunpatidar @Suraj_Kamdi 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

you have to handle this at clientside with show/hide logic.

1. Render both desktop and mobile version

2. Show/hide based on device type. 

 

4 Replies

Avatar

Community Advisor

@Vanitha_Duraisamy If you are testing in chrome browser's developer tools its buggy. Firefox is better for UI Testing. Best is to test it in actual mobile device from my experience.

Avatar

Level 2

Thanks @Saravanan_Dharmaraj 

We are facing the same issue on actual device as well.

Its fetching the desktop code on mobile device intermittently.

 

The correct code is fetched only when we use query parameters and load the page without cache.

Avatar

Correct answer by
Community Advisor

you have to handle this at clientside with show/hide logic.

1. Render both desktop and mobile version

2. Show/hide based on device type. 

 

Avatar

Employee Advisor

The problem is that you have 2 versions of your site:

  • mobile
  • non-mobile

 

but you are caching the result just with 1 name ("page.html"). You need to have a dedicated name for each version. But even better is @arunpatidar 's suggestion to make the rendered page agnostic of the device and handle everything on the client side.