Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7551427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:29:31+00:00 2026-05-30T10:29:31+00:00

I wrote a gravatar helper to use in my learning app. The Users#index action

  • 0

I wrote a gravatar helper to use in my learning app. The Users#index action lists all users with their gravatars, which can take a while even with pagination. Is there a way to cache the gravatars in Rails 3.2 with the following in mind:

  1. Without using a Gravatar plugin that has a cache feature.
  2. Without caching the users page itself; really, I’m only looking to cache the images themselves without having to grab them from gravatar.com again.

    def gravatar_for(user, options = { size: 50 })  
        gravatar_id  = Digest::MD5::hexdigest(user.email.downcase)
        size = options[:size]
        gravatar_url = "http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}"
        image_tag(gravatar_url, alt: user.name)
    end
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:29:32+00:00Added an answer on May 30, 2026 at 10:29 am

    Caching the entire users page or fragment caching the image urls wouldn’t make a difference anyway because the images will still be downloaded from Gravatar. Gravatar sets their Cache-Control header to have a max age of 5 minutes and there’s not much else you can do about it.

    One possibility is to save the images to another location where you have control over the response headers.

    One minor thing you could do during development though is to not use a hard refresh on your pages. In some browsers CMD/CTRL + R or pressing the refresh button sends request headers with Cache-Control:max-age=0 which causes you to re-download all the images. You can do a soft refresh by simply visiting the page again (for example: pressing enter on the url in the addressbar) and it won’t send that header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a makefile which behaves oddly. You can find it here: http://pastebit.com/pastie/8215 Basically
I wrote an android app, which requires large amount of data to be transfered
I wrote an app to automatically connect to our different Firewalls. All of them
I wrote a grid helper (GridHelper.cs), it works right for all models. This Helper
I wrote code in which .getJSON api from jquery is used to fetch images
I wrote a code which copies an answer in calculator to clipboard, then calculator
I wrote this, and wanted to get everyones opinion. I use this when I'm
I wrote an app in Visual Studio and is about 20k+ lines, but I
I wrote an little app in C# to keep track of customers and jobs
I wrote a simple opengl application in C which plots sin(x). This is my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.