Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


timmmay

20582 posts

Uber Geek

Trusted
Lifetime subscriber

#171346 14-Apr-2015 19:39
Send private message

Google has a big mobile push on at the moment. If your website isn't fast and highly optimised for mobile devices you get kicked down the rankings from April 21st apparently. Tester here.

I have a wordpress website with responsive design css, but the images served to mobiles are still full size. I tried dynamically resizing images based on the client using .htaccess and a pretty cool php adaptive images script but as filenames don't change this isn't compatible with my CDN. The CDN (Cloudflare Free) is set to cache images (of course) and it caches the first image that comes back, whether it's desktop or mobile, so I'd need to turn off image caching and lose most of the advantage of the CDN. Doing it with Javascript to rewrite the page is kinda messy, and if you make substitutions apparently it can end up loading both sets of images.

I figure the cleanest way to do this is in PHP, detecting the user agent and generating/rewriting the html based on the user agent. The mobile site html can refer to smaller images, which will have to be generated somehow, in advance ideally, or cached. That means you can't cache html, but oh well. Does anyone know a good way to do this, maybe a wordpress plugin? Does anyone have any alternate suggestions?

Create new topic
freitasm
BDFL - Memuneh
79295 posts

Uber Geek

Administrator
ID Verified
Trusted
Geekzone
Lifetime subscriber

  #1283215 14-Apr-2015 20:33
Send private message

Do you have the option to add a query string to the image name? You could add a querystring to the image name and configure Cloudflare to cache different querystrings - for example www.example.com/image?width=300 or www.example.com/image?width=150.




Please support Geekzone by subscribing, or using one of our referral links: Quic Broadband (free setup code: R587125ERQ6VE) | Samsung | AliExpress | Wise | Sharesies | Hatch | GoodSync 




timmmay

20582 posts

Uber Geek

Trusted
Lifetime subscriber

  #1283217 14-Apr-2015 20:35
Send private message

I might be able to, but query strings tend to prevent caching, which I find important for images. My server's a shared one in the US, page load times are 9 seconds natively, 2 seconds with Cloudflare.

I think I'm going to have to manually change Wordpress.

freitasm
BDFL - Memuneh
79295 posts

Uber Geek

Administrator
ID Verified
Trusted
Geekzone
Lifetime subscriber

  #1283231 14-Apr-2015 20:41
Send private message

Check the Cloudflare settings - they have an option to cache at different levels, with and without querystrings.





Please support Geekzone by subscribing, or using one of our referral links: Quic Broadband (free setup code: R587125ERQ6VE) | Samsung | AliExpress | Wise | Sharesies | Hatch | GoodSync 




timmmay

20582 posts

Uber Geek

Trusted
Lifetime subscriber

  #1283235 14-Apr-2015 20:45
Send private message

Yep it does, I just don't trust caching anything with query strings. In wordpress they often refer to js files with abc.js?ver=123, I strip those out with a plugin and it makes performance tests faster generally. Plus I'd have to manually code that up I think. Thanks for the idea.

I also found this, which I'll give a go.

jnimmo
1097 posts

Uber Geek


  #1283255 14-Apr-2015 21:10
Send private message

Yeah was about to suggest looking for a WP plugin. Can do retina images for you at the same time ; file names instead of query str

timmmay

20582 posts

Uber Geek

Trusted
Lifetime subscriber

  #1283275 14-Apr-2015 21:21
Send private message

I only have 800px wide images, I figure people with retina displays will be used to standard sizes anyway.

I'm looking down the path of detecting whether the viewer is on mobile using the mobble plugin, if they are somehow forcing the gallery tag to use the size="medium" parameter, which shows 400px wide images which are much smaller files. I may hard code it (hope not), hopefully someone can suggest a plugin that does it, or worst case I could probably work out how to write a wordpress plugin - I don't much like PHP though.

The Responsify WP plugin seems to do exactly what I want :)

Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.