Plugin

Developer
Supported

EE 1
EE 2
CE Image

Back to this add-on's main page
View Other Add-ons From Causing Effect

1 of 2
1
   

You must be logged in to post.

Remote image performance

Support (Resolved)

Daniel
Daniel

Just wondering if there is any differences in performance between a single image tag and the tag pair?

The reason I’m asking is that I have a single entry page that will have a gallery of cake images (up to 8 images) in it as well as a carousel of thumbs (lots and lots of images) for other cakes within that category.
I’m currently using the single image tag but would you recommend using one tag over the other for these purposes?

Also I’m using your plugin in combination with the Flickr addon and pixel and tonic’s matrix field type. All remote and local images are being cached just fine.

The page seems to be bogged down big time—taking up to 9 seconds to load on a local install—and from the logs it looks like it is ce_image that is hogging that time.

Here is a screen shot of the page to give you some idea of what i’m talking about.
Here is the template debugging
And finally the code I am using to pull out the gallery images.

Any thoughts on how to speed up performance would be greatly appreciated.


Thanks
Dan

Causing Effect - Aaron Waldon
# 1
Developer
Causing Effect - Aaron Waldon

Hi Daniel!

No, there is no difference in performance between the single and tag pairs, from the perspective of the plugin.  EE itself can probably parse the tag pair faster, as it will be able to find the closing tag faster than determining that there is not one, but that speed difference should be negligible.

Once CE Image has created a manipulated image, it is cached. Subsequent calls should be very quick, because a minimal amount of processing is performed to determine the image name and check the cache.

I think the speed problem in this case, is due to a feature… CE Image always attempts to ensure that the image being used is the latest, so that the manipulated images always reflect the source image. This is nice to have so that you don’t have to go and clear your cached images every time you change an image; it automatically updates itself. The same goes for remote images, but the problem is, if the remote server takes a while to respond, you get the lag.

With a simple change, we should be able to enhance performance of your remote images drastically by disabling this check. Assuming you are using the EE2 version of the latest version, please change line 1309 from this:

if ( function_exists'curl_init' ) ) 

to this:

if ( FALSE //if ( function_exists( 'curl_init' ) ) 

That will prevent the plugin from checking if the remote image has been updated on every call, and will instead periodically re-download the remote image (you can specify the amount of time to do so with the remote_cache_time setting).

I am going to rethink this default functionality for the upcoming release of CE Image. Thanks for the feedback Daniel!

Please let me know if that helps.

Daniel
# 2
Daniel

Aaron thanks for the quick response,

Changing that line of code worked great, thanks for that.

On a separate note…
I’m using a single index template to serve the section overview, category overview and single cake page views. Why would the plugin be parsed (not sure if that is the right terminology) even if a condition is not true?

Example:

{if segment_1 =="cakes" && segment_2 ==""}
 {
!-- CAKES OVERVIEW CODE --}

{if
:elseif segment_2 !="" && segment_3 ==""}
{
!-- CATEGORY PAGE CODE --}

{if
:elseif segment_3 !=""}
{
!-- SINGLE CAKE PAGE CODE --}

{
/if} 

I’m not using your plugin anywhere for that first condition. However when the page is loaded, the template debugging shows that all the single image tags from the category page code and single page code are being requested, even if not shown.
This doesn’t happen if I embed the category and single page blocks of code.

Is this normal behaviour for EE2?

Here is the debugging code for that overview page when all code is in the index template.
And here it is when those blocks are embedded.

Many thanks
Dan

Causing Effect - Aaron Waldon
# 3
Developer
Causing Effect - Aaron Waldon

It is all about EE’s parsing order with the conditionals. A nice solution is to use Switchee. Take a look at this thread that addresses the issue: http://devot-ee.com/add-ons/support/ce-image/viewthread/694/

Daniel
# 4
Daniel

Sweet thought that parsing oder might be the issue. Will have a look at switchee.

Thanks again Aaron.
Dan

Causing Effect - Aaron Waldon
# 5
Developer
Causing Effect - Aaron Waldon

No problem. Have a good one Dan!

Milan Topalov
# 6
Milan Topalov
Aaron Waldon (Causing Effect) - 06 April 2011 12:53 AM

That will prevent the plugin from checking if the remote image has been updated on every call, and will instead periodically re-download the remote image (you can specify the amount of time to do so with the remote_cache_time setting).

I am going to rethink this default functionality for the upcoming release of CE Image. Thanks for the feedback Daniel!

I second this feature (request) :-)

Checking for remote image updates on every load is just too expensive - especially if the template uses large number of images.

Using EE built-in template caching helps alleviate the problem - unless you’re embedding the particular template in e.g. website footer :P

Causing Effect - Aaron Waldon
# 7
Developer
Causing Effect - Aaron Waldon

This has already been changed in my dev version and will be fixed in the next release. :) The plugin only requests the headers (to try and see if the image has changed), but being at the mercy of a remote server can be costly, especially if it has a sub par response time.

Causing Effect - Aaron Waldon
# 8
Developer
Causing Effect - Aaron Waldon

Another way to boost performance and completely get around this issue is to enable tag caching: http://www.causingeffect.com/software/ee/ce_img#performance

The new images will only be checked when the cache expires. Which is an ideal scenario! I don’t know how I forgot about this before…

Causing Effect - Aaron Waldon
# 9
Developer
Causing Effect - Aaron Waldon

Just to let you gentlemen know, this has been addressed in the upcoming release! :) Thanks for the feedback.

Simon Clayson
# 10
Simon Clayson

Hi. I’m checking in here as it’s neat and tidy way to ask for a bit of clarification>

So, I’m all up-to-date and using CE Image and EE Hive’s Flickr. It all works and images are created nicely from the remote ones. However, performance is still so slow, and the only thing I can put it down to is that Flickr is being called each time to check is the image has been updated, even though it’s not downloading it. So, to clarify, whats the best way to completely turn off any remote check as of March 2013 and rely on the cached image?

Causing Effect - Aaron Waldon
# 11
Developer
Causing Effect - Aaron Waldon

Hi Simon!

The remote images are downloaded once, and are not checked unless the remote_cache_time config setting is changed in the config. However, checking to see if a large image is cached can still be a little slow. I’m actually working on improving that a bit for a future release. I highly recommend caching, even if only tag caching. It saves a bit of work for the server and will make the page load a lot faster. Please take a look at the Performance page for more information on caching.

Does that make sense? Please let me know if you have any questions.

Simon Clayson
# 12
Simon Clayson

Aaron. Thanks for the quick reply.

So, I think I understand, I’m caching everything as far as I’m aware. And, as far as I get it, once the image has been cached locally, there are no calls to the remote server at all, not even to check for changes.

Here’s my code - it’s pretty simple… just slow!

{exp:eehive_flickr:photo photo_id="{flickr_photo_id}" parse="inward"}
    {exp
:ce_img:pair src="{flickr_url_medium}" quality="60"}
     
<img src="{made}" alt="{flickr_title}" />
    
{/exp:ce_img:pair}
   {
/exp:eehive_flickr:photo} 

Should be fine?

Causing Effect - Aaron Waldon
# 13
Developer
Causing Effect - Aaron Waldon

Your code looks fine, and unless you have the remote_cache_time setting specified in your config, the remote image will not be updated. However, you can still implement caching in your templates to make things even faster (take a look at the Performance page for more details).

For example, changing your code to use ExpressionEngine’s native tag caching

{exp:eehive_flickr:photo photo_id="{flickr_photo_id}" parse="inward" cache="yes" refresh="360"}
    {exp
:ce_img:pair src="{flickr_url_medium}" quality="60"}
     
<img src="{made}" alt="{flickr_title}" />
    
{/exp:ce_img:pair}
{
/exp:eehive_flickr:photo} 

would ensure that the Flickr and CE Image exp tags for a specific id in the above example would not need to be called for six hours (360 minutes) after they are cached. The cached results for each tag would simply be returned by the EE template parser during that window of time.

Does that make sense?

Simon Clayson
# 14
Simon Clayson

I think that’s helped thanks! Initial load (for a page for 8 medium images is about 25secs) then, down to less than a second.

Thanks for all your help - much appreciated!
Simon

Causing Effect - Aaron Waldon
# 15
Developer
Causing Effect - Aaron Waldon

Wait, 25 seconds?! That’s crazy. How much of that is coming from the Flickr add-on? Also, what debug info do you get for CE Image and the other add-on (see Debugging for more info)?

1 of 2
1