Pre-cache Mobile pages

#1
I am using OpenCart 2.3.0.2 with the LiteSpeed Cache Extension for OpenCart with Journal 3.2. I have pre-cached the website with LiteSpeed Cache, however, I see "miss" (as in the cache is not prepared) for mobile pages of the website.

I think there is an issue with my .htaccess...
 
Last edited:

serpent_driver

Well-Known Member
#3
You are asking your question in the wrong forum because you first need a function for OC that creates webp images or converts the ones that already exist and then you need another function that only displays webp images if a browser supports this image format . However, these functions have nothing to do with LiteSpeed and the cache plugin. So ask in the OC forum for a solution.
 

serpent_driver

Well-Known Member
#5
You said, that you have OC version 2.x, but you use Journal 3.x. The question is how Journal detects if a browser supports webp?! Depending on this detection the cache vary must be synchronized.

FYI: If using webp the cache warmup no longer works.
 
#7
You said, that you have OC version 2.x, but you use Journal 3.x. The question is how Journal detects if a browser supports webp?! Depending on this detection the cache vary must be synchronized.

FYI: If using webp the cache warmup no longer works.
If only I knew how to code. This would be the best solution for each image:
<picture>
<source srcset=”image.webp” type=”image/webp”>
<source srcset=”image.jpg” type=”image/jpeg”>
<img src=”image.jpg”>
</picture>
I'm not sure what Journal does for mobile devices exactly but it makes some detection for tablet & mobile because the images are resized differently.
 

serpent_driver

Well-Known Member
#8
If you use
Code:
<picture>
element there is no need for extra cache copy, because the browser itself decides which image format he supports. An extra cache copy is therefore obsolete and you don't need to add aditional cache vary for this.
 

serpent_driver

Well-Known Member
#10
According to the documentation, different versions or different code are used for mobile devices and desktop devices. The screen resolution is irrelevant because, according to the documentation, the user agent decides which code is used for which device.

The scope of functions of the OC cache extension does not provide for a device-dependent cache warmup. You therefore only have the option of using the Magento Cache Crawler, which can only be used in the console (CLI), or you can choose the Kitt Cache Crawler.
 
#11
There is a setting in OpenCart LS Cache that says: "Rebuild Cache for specific devices/browsers" and then "Input User Agent of your device browser, one User Agent per line"

What values will this accept?
 

serpent_driver

Well-Known Member
#14
Enter this

Code:
Mobile
Android
Silk/
Kindle
BlackBerry
Opera Mini
Opera Mobi
It is not guaranteed that these user agents ensure complete synchronicity between the cache plugin and Journal because I don't know whether Journal differentiates between iPhone and mobile devices. This differentiation would be necessary when it comes to supporting webp images. I don't see any of this in the settings or code of the cache plugin.
 
#16
I've been playing around with it. If I do just iPhone in this field, then the image dimensions generate correctly (smaller images). However, a mobile version is served on desktop. Then, if I do iPhone & Macintosh it creates only desktop versions for both iPhone and Macintosh. What is going on here? Is there a bug?
 

serpent_driver

Well-Known Member
#17
It does not work like that. The terms entered are search terms that are used to search for these words in the user agent string. The term "iPhone" is included in the user agent for the Safari browser on iPhones, but not "iPhone & Macintosh". That's why the search result is false.

You don't have to enter the term "iphone" because the term "mobile" already contains the necessary term for mobile devices.
 
#18
I entered them on separate lines. So multiple user agents should be in effect:

iPhone
Mac

Also what if I am using these varies

Code:
#1
RewriteCond %{HTTP_USER_AGENT} windows|linux|mac [NC]
RewriteCond %{HTTP_ACCEPT} "image/webp"
RewriteCond %{HTTP_USER_AGENT} !mobile|bot|chrome-lighthouse [NC]
RewriteRule .* - [E=Cache-Control:vary=isDesktop]

#2
RewriteCond %{HTTP_USER_AGENT} version/(\d{2}).*safari [NC]
RewriteCond %1 <14
RewriteCond %{HTTP_USER_AGENT} !mobile|bot|chrome-lighthouse [NC]
RewriteRule .* - [E=Cache-Control:vary=isDesktopNoWebpSafari]

#3
RewriteCond %{HTTP_USER_AGENT} version/(\d{2}).*safari [NC]
RewriteCond %1 >13
RewriteCond %{HTTP_USER_AGENT} !mobile|bot|chrome-lighthouse [NC]
RewriteRule .* - [E=Cache-Control:vary=isDesktopWebpSafari]

#4
RewriteCond %{HTTP_USER_AGENT} android|silk/|kindle|blackberry|opera\ mini|opera\ mobi|crios|fxios [NC]
RewriteCond %{HTTP_ACCEPT} "image/webp"
RewriteCond %{HTTP_USER_AGENT} !bot|chrome-lighthouse [NC]
RewriteRule .* - [E=Cache-Control:vary=isMobile]

#5
RewriteCond %{HTTP_USER_AGENT} version/(\d{2}).*mobile.*safari [NC]
RewriteCond %1 <14
RewriteCond %{HTTP_USER_AGENT} !bot|chrome-lighthouse [NC]
RewriteRule .* - [E=Cache-Control:vary=isMobileNoWebpSafari]

#6
RewriteCond %{HTTP_USER_AGENT} version/(\d{2}).*mobile.*safari [NC]
RewriteCond %1 >13
RewriteCond %{HTTP_USER_AGENT} !bot|chrome-lighthouse [NC]
RewriteRule .* - [E=Cache-Control:vary=isMobileWebpSafari]

#7
RewriteCond %{HTTP:Sec-Fetch-Dest} ^$ [NC]
RewriteCond %{HTTP:Sec-Fetch-Mode} ^$ [NC]
RewriteCond %{HTTP:Sec-Fetch-Site} ^$ [NC]
RewriteCond %{HTTP:Sec-Fetch-User} ^$ [NC]
RewriteCond %{HTTP_USER_AGENT} !version/.*safari [NC]
RewriteRule .* - [E=Cache-Control:vary=isBot]

#7
RewriteCond %{HTTP_USER_AGENT} applebot [NC]
RewriteCond %{HTTP_USER_AGENT} !mobile [NC]
RewriteRule .* - [E=Cache-Control:vary=isBot]

#8
RewriteCond %{HTTP:Sec-Fetch-Dest} ^$ [NC]
RewriteCond %{HTTP:Sec-Fetch-Mode} ^$ [NC]
RewriteCond %{HTTP:Sec-Fetch-Site} ^$ [NC]
RewriteCond %{HTTP:Sec-Fetch-User} ^$ [NC]
RewriteCond %{HTTP_USER_AGENT} mobile [NC]
RewriteCond %{HTTP_USER_AGENT} !version/.*safari [NC]
RewriteRule .* - [E=Cache-Control:vary=isMobileBot]

#8
RewriteCond %{HTTP_USER_AGENT} applebot [NC]
RewriteCond %{HTTP_USER_AGENT} mobile [NC]
RewriteRule .* - [E=Cache-Control:vary=isMobileBot]
</IfModule>
 

serpent_driver

Well-Known Member
#19
"Mac" and "Macintosh" is for all Apple devices, also for Deskop device, so don't enter it. The cache plugin has default terms for mobile devices already defined, so you don't have to enter additional terms.

My cache varies in .htacces are much more accurate than the plugin's cache varies.
 
Top