495 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+8 more
pixelentity says

To avoid that caching issue why don’t we use a PHP session for that? Each time a retina device opens the page a session is created setting a PHP variable to true. This should fix that, right?
No, it won’t unless you disable page caching for mobile devices.
622 posts Fuel Your Web
  • Elite Author: Sold more than $75,000 on Envato Market
  • Won a competition
  • Had an item featured on Envato Market
  • Has been part of the Envato Community for over 7 years
+5 more
Pirenko says


To avoid that caching issue why don’t we use a PHP session for that? Each time a retina device opens the page a session is created setting a PHP variable to true. This should fix that, right? I’m currently coding a solution with sessions that seems to be working…
you can’t detect retina via php
I know, but it would be so easy if we could :)
My idea at this moment is:
1) Page loads and with javascript we check if it’s a retina display.
2.a) No retina display and the pages loads normally;
2.b) Argh! It’s a retina display! We create a PHP session and store a PHP variable saying that. The next time the page loads we have this variable on the header and we can add classes to images or resize them accordingly.
622 posts Fuel Your Web
  • Elite Author: Sold more than $75,000 on Envato Market
  • Won a competition
  • Had an item featured on Envato Market
  • Has been part of the Envato Community for over 7 years
+5 more
Pirenko says


To avoid that caching issue why don’t we use a PHP session for that? Each time a retina device opens the page a session is created setting a PHP variable to true. This should fix that, right?
No, it won’t unless you disable page caching for mobile devices.
As far as I know sessions are created each time you open a website after a long period or after having closed and opened the browser application. So there’s no caching thing here. At least it seems to be like this to me ;)
495 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+8 more
pixelentity says

As far as I know sessions are created each time you open a website after a long period or after having closed and opened the browser application. So there’s no caching thing here. At least it seems to be like this to me ;)
Page caching plugins create a static html version of the page which is served by the webserver directly using .htaccess rules, no php is involved in the process.
622 posts Fuel Your Web
  • Elite Author: Sold more than $75,000 on Envato Market
  • Won a competition
  • Had an item featured on Envato Market
  • Has been part of the Envato Community for over 7 years
+5 more
Pirenko says

So you are saying that I can’t create PHP sessions when a caching plugin is enabled? This does not make sense to me :S

495 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+8 more
pixelentity says

So you are saying that I can’t create PHP sessions when a caching plugin is enabled? This does not make sense to me :S
To serve static html (where possible) is several times faster than using php generated content, around 100x if you consider the average wp page. Server side device dependent markup would make full page caching almost impossible, much harder at the very least and to serve images via php would be even worst. A client side (js) solution would be cache friendly and should be preferred.
by
by
by
by
by
by