I got the problem that my localhost got really slow respond times and I think I hunted the problem down to the thumbnail creation process. At the moment I need ~12 seconds for every page refresh which drives me crazy.
First I thought it is a problem with xampp or something but I guess it is my code. I am generating a simple image gallery with ~15 images and create smaller thumbnails for each image and a bigger version for when you click on it. If I comment out this code the loading times go from ~12 down to ~3-4 seconds (which would be respectable but still not very fast)
<?php 
	$count = 0;
	$images = $module->images()->sortBy('sort', 'asc'); 
?>
<?php foreach($images as $image): ?>
       <?php $thumb = thumb($image, array('width' => 1300, 'quality' => 80, 'crop' => false), true); ?>
	<?php ++$count; ?>
	<figure class="4u<?php ecco($count % 3 == 0, '$', '') ?> 6u<?php ecco($count % 2 == 0, '$', '') ?>(narrow) 12u(mobile)">
	   <a href="<?php echo $thumb->url() ?>" data-size="<?php echo $thumb->width() . 'x' . $thumb->height() ?>">
              <img data-src="<?php echo thumb($image, array('width' => 400, 'height' => 266, 'quality' => 80, 'crop' => true), false) ?>" alt="<?php echo $image->caption(); ?>" />
	   </a>
	   <figcaption><?php echo $image->caption(); ?></figcaption>
	</figure>
<?php endforeach ?>
Now I question myself why this slows down my page (the server respond time) so much? Doesn’t kirby recognize when the thumbnails are already created and will just serve them? How could I improve my code so that it’s faster?
Any ideas of what common pitfalls for performance issues can be? I also often need something like $pages->find('somePage'); is this a problem or is there a better way to serve a page that you often need (instead of searching it)?
