Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow page loading times #143

Open
Pjero opened this issue Feb 22, 2017 · 1 comment
Open

Slow page loading times #143

Pjero opened this issue Feb 22, 2017 · 1 comment

Comments

@Pjero
Copy link

Pjero commented Feb 22, 2017

I've implemented a gallery on one of my projects using the code from the readme and the page load times in production on the gallery page are incredibly slow. I only need a gallery with 10 images max, but it is slow with just 4.

The view code:

 <%- @page.images.each do |image| %>
      <figure>
        <a href=<%= image.thumbnail(geometry: "1024x").url %> data-size=<%= "#{image.thumbnail(geometry: "1024x").width}x#{image.thumbnail(geometry: "1024x").height}" %> data-turbolinks="false">
          <%= image_fu image, '283x223#', alt: "Image description", itemprop: "thumbnail" %>
        </a>
        <figcaption itemprop="caption description"><%=image.title %></figcaption>

      </figure>
  <% end %>

I've tried it on another page (on a different and faster server) with the same results.

@stefanspicer
Copy link

We've had problems with cropping images being slow and using more memory that we'd like (taking our server out). Here's our current solution to deal with this:

routes.rb:
get '/system/images/:job/:filename', constraints: lambda { |request| request.params[:filename] !~ /^image.[\w]+{2,5}/ },
to: redirect { |params, request| "/system/images/#{params[:job]}/image#{Rack::Mime::MIME_TYPES.invert[request.format.to_str]}#{'?' + request.query_string if request.query_string.present?}" }

refinery/images/dragonfly.rb:
app_images.configure do
[...]
if Refinery::Images.dragonfly_use_local_cache
before_serve do |job, env|
job.to_file("#{Rails.root}/public#{app_images.server.url_for(job).sub(/?.*$/, '')}.#{job.ext}")
end
end
end

This saves the images in /public dir for apache or nginx to serve up directly next time and essentially caches it forever. We don't have a problem with caching forever because we don't allow editing of images. Every uploaded image is a new Refinery::Image in the DB. The extra route above just stops someone from fetching abcdefghijkl.jpg, abcdefghijk.jpg, abcdefghij.jpg, abcdefghi.jpg, abcdefgh.jpg, abcdefg.jpg, abcdef.jpg, abcd.jpg, abc.jpg (we had someone take out the server with convert processes once in this way)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants