0

I'm working to a site for cloud file management with CakePHP, where user can upload numerous files like images, documents, pdf etc. and all those uploaded files will be in aws s3 bucket, nothing in local.

These document will be load using jstree ie. when user click on a jstree folder corresponding documents of that folder will load in view via AJAX.

Now the problem is that, its taking a huge amount of time to load corresponding files of a folder when there are numerous files. For example: I've a folder with 50+ images and also with some doc files. When I select that folders it takes couple of minutes time to load that folder and every time it takes that amount of time.

I already used cache for that ajax loaded view and also set cache : true in jquery ajax setup to that view file.

Something like:

public $cacheAction = array(
  'index' => 36000,
  'ajax_documents' => 3600 // this is the view file that render documents
);

.....
public function ajax_documents() {
   // Here is all query data that set to corresponding ajax_document.ctp file
   // I also cached the query result for each folder request
}

And in jQuery

$.ajax({
  type: 'GET',
  cache: true,
  ifModified: true,
  data : {},
  url: '..ajax_documents',
  ......
});

But nothing is working. Still it takes huge amount of time to render ajax_document.ctp. File caching is working properly cause I'm seeing them.

So in this situation I need your help and suggestion how to boost up this loding and what is best way to follow for this kind of situation?

NOTE:

The Main problem is the loading of images from s3 on each time view load. So I need basically the solution for that image cache.

Please help me with this.

thaJeztah
  • 27,738
  • 9
  • 73
  • 92
The System Restart
  • 2,873
  • 19
  • 28
  • Have you tried to narrow down what the bottleneck is? Is the problem retrieving the list of documents? Loading the documents? The code provided in your question doesn't offer information on that part. – thaJeztah Mar 18 '13 at 19:10
  • Unfortunately, I do not have any experience with Amazon s3, but a quick search on 'cache control for s3'; http://stackoverflow.com/questions/10435334/set-cache-control-for-entire-s3-bucket-automatically-using-bucket-policies and this http://www.labnol.org/internet/lower-amazon-s3-bill-improve-website-loading-time/5193/ Maybe those links can help you further? – thaJeztah Mar 18 '13 at 20:49

1 Answers1

0

You could try to compress the files on the filesystem but to be honest you are going to be better off having your images hosted on a CDN service of some sort where they have their own caching happening and use their url to load your images.

I know this from experience at my job. We use cake 1.3. Caching from cake is terrible in general even with an effective memcache. Use a CDN.

Shawn
  • 3,583
  • 8
  • 46
  • 63
  • 3
    I'm really wondering what the OP means with 'it takes minutes to load'. If the view itself is cached in cakephp, rendering it can *never* take minutes. I suspect that either loading the actual images in the browser takes time, or something else is done inside the controller or view. Also CakePHP caching does not influence loading of images etc, only the view itself. To cache images, proper cache-headers should be sent by the webserver – thaJeztah Mar 18 '13 at 19:41
  • @thaJeztah yes Sir, my main issue is the image caching. So please help me with that image caching issue those are loading from s3 each time view refreshed by ajax with folder selection – The System Restart Mar 18 '13 at 20:43