Calling file at each Timthumb run

Asked

Viewed 931 times

3

Use the Timthumb to upload images and resize them. However, at the end of the project, making modifications to the .htaccess for optimization (enabling gzip, Minify, Leverage browser caching and more), persisted something I consider error:

Timthumb is running once, on each image, note in the figure below: note o carregamento de diversos tim.php

Would there be any method for me to make a Loop in the script? Each tim.php reported in the image above is an image loaded by it, the Urls are being shown as follows:

http://meusite.com.br/tim.php?src=http://meusite.com.br/uploads/2013/11/nomedaimg&w=160&h=80&zc=1&q=100&a=t

My site is taking 5 seconds to open, it’s bothering a lot.

2 answers

0

Ajax to avoid user waiting

Good morning, have you considered passing an array with src of the images to a function that looped Timthumb, catching the result by ajax? I think that would be interesting.

Resizing only once.

Another thing. wordpress for example generates all thumbnails one time, several default dimensions, not being necessary to redo them each refresh page. That way, following this idea is very valid.

You would generate various sizes (if necessary) or the size you want.

  1. Thumbnail (150px x x 150px standard)
  2. Medium size (300px x x 300px standard)
  3. Full size (640px x x 640px standard)
  4. Original size (unmodified)

After that, you could check the existence of the thumbnails specific folder for each image, if you do not want to keep the history in a table in the BD.

  • Luiz just edited the question... rsrs

  • kkkk sorry. I’m still sleepy. :/

0


After knowing a little about this image library and analyzing the question graph, I can comment on some possible causes of slowness...

Timthumb is always processing all images

This does not seem to be the case, since several lines of the graphics show only green bars, which means that time was spent on image transfer and no processing.

Note that it doesn’t make much difference the URL being tim.php, provided that the library is only writing an image in cache to the exit as this is fast.

Anyway, make sure the images are being saved in the directory set up for caching. If they are not, adjust the script permission for the folder.

Timthumb is sending some header that prevents caching

Use the developer tool of your browser (F12?) to monitor the network and check whether, after accessing the same page a second time, the images will be loaded from the browser cache and not done the download again.

Your server is slow

Honestly, for some shared hosts, 5 seconds is up to a reasonable time for the level of processing your website seems to be using. I even use the Bluehost for my blog and, if it were not for the Wordpress cache plugins, the loading time could easily reach twice that.

Large number of downloaded files

Another factor seen in the chart is that there is a large number of downloaded elements in the page access. This also causes a negative impact, even if your network bandwidth is good, as browsers limit the number of simultaneous connections. The limit is usually between 2 and 6 connections (see this SOEN response).

However, this would be well mitigated in your case after the second access to the site, because at least the web fonts, styles and scripts would be cached in the browser. Of course the price would be paid on first access, but if the content is good it is worth it.

Completion

I’m inclined to think there’s no specific problem with Timthumb.

I would do some tests by placing still images and also checking if the browser can use the cache properly and load the page faster from the second access.

Finally, if the issue was performance, there are techniques to improve this, such as hiring a more powerful server or even more specialized cloud caching services.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.