Differences
This shows you the differences between two versions of the page.
Last revision Both sides next revision | |||
litespeed_wiki:cache:developer_guide:mobile-vary [2019/08/20 00:02] qtwrk created |
litespeed_wiki:cache:developer_guide:mobile-vary [2019/08/20 15:09] Kacey Schroeder proofread |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | This is a simple example for cache vary based on devices , as classified in desktop , mobile and tablets. | + | This is a simple example of cache vary based on devices, divided by desktop, mobile and tablet. |
Chrome 76 on Windows 10: | Chrome 76 on Windows 10: | ||
Line 16: | Line 16: | ||
Mozilla/5.0 (iPad; CPU OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/16A5288q Safari/605.1.15 | Mozilla/5.0 (iPad; CPU OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/16A5288q Safari/605.1.15 | ||
- | For above exemplary user agent, we will use ''Android'' or ''iPad'' in user agent to detect tablets , use ''iPhone'' or''Mobile'' to detect mobile , and consider all of rest are desktop, this is a simple solution , but it should cover most cases though, the rules can be further extended to match more specific cases. | + | For the above exemplary user agent, we will use ''Android'' or ''iPad'' as the user agent to detect tablets , use ''iPhone'' or ''Mobile'' to detect mobile, and consider all the rest desktop. This is a simple solution but it should cover most cases. The rules can be further extended to match more specific cases. |
Line 43: | Line 43: | ||
</code> | </code> | ||
- | First rule will cache every page for 120 seconds. | + | The first rule will cache every page for 120 seconds. |
- | Second rule will check user agent , if it contains keyword ''iPad'' or ''Android'' , it will set vary to ''istablet'' and on next rule , if the user agent also contains ''Mobile'' as from Android Mobile device, it will set vary to ''ismobile'' and all other user agents are treated as desktop. | + | The second rule will check the user agent. If it contains the keyword ''iPad'' or ''Android'' it will set vary to ''istablet''. If the user agent ALSO contains the keyword ''Mobile'' though, such as from an Android Mobile device, it will set vary to ''ismobile'' instead of ''istablet''. All other user agents are treated as desktop. |
Line 113: | Line 113: | ||
Alt-Svc: quic=":443"; ma=2592000; v="39,43,46", h3-22=":443"; ma=2592000 | Alt-Svc: quic=":443"; ma=2592000; v="39,43,46", h3-22=":443"; ma=2592000 | ||
- | this is Desktop view</code> | + | This is Desktop view</code> |
<code>[root@test ~]# curl https://example.com/test.php -i -H "User-Agent: others" | <code>[root@test ~]# curl https://example.com/test.php -i -H "User-Agent: others" | ||
Line 126: | Line 126: | ||
Alt-Svc: quic=":443"; ma=2592000; v="39,43,46", h3-22=":443"; ma=2592000 | Alt-Svc: quic=":443"; ma=2592000; v="39,43,46", h3-22=":443"; ma=2592000 | ||
- | this is Desktop view</code> | + | This is Desktop view</code> |
- | So each device hit cache and showing varied cached content. | + | So each device hit cache and is showing varied cached content. |