Are you uploading them as private or public? If they are private the reason why they would no longer be accessible from that url after 20-30 minutes is the permissions token on the image, which would be provided by the avatar_url method, is expiring meaning the S3 will respond with 404 file not found.
Make the images public, or try something like the following instead
<% cache(["homeimages", post], :expires_in => 20.minutes) do %>
<%= link_to image_tag(post.avatar_url), post %>
<% end %>
The 20.minutes being what ever time the access token last. Meaning the cache will never outlast the token.
Edit
Also you do realize that your not "caching the images with memecached/dalli", but rather the img tag?