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 6620611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:07:27+00:00 2026-05-25T21:07:27+00:00

OK, I am a newbee to stackoverflow. Developing an ecommerce site, I have as

  • 0

OK, I am a newbee to stackoverflow.

Developing an ecommerce site, I have as many as 50 unique images on the home page that needs to be loaded. I am using the Amazon CDN for my images and all these files are in a bucket with a unique domain.

I would like to have multiple domains mapped to this bucket. However for each image, I should be able to find at runtime, which domain it was servered last time so that the caching is most optimized. My idea is to have a function func(filename) which can return a value between 0-9 every-time for the same filename. This can be used for the domain name.

I do not want the func to be very heavy like a hash and in this case, I would want a collision rather than avoid it.

A simple method would be to use a intval(filename) and then use the least significant digit. However I am not sure this would be a good solution and if the spread would be balanced.

Any suggestions ?

  • 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-25T21:07:28+00:00Added an answer on May 25, 2026 at 9:07 pm

    How about something as simple as this:

    function customHash($str) {
        $hash = 0;
    
        for ($i = 0; $i < strlen($str); $i++) {
            $hash += ord($str[$i]);
        }
    
        return $hash % 10;
    }
    

    You can optimize this in many ways, like using iconv_strlen() to treat utf-8 strings right and instead of the whole length, $len = max(6, $strlen); could be used (though the perfomance boost isn’t really significant…).

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

Sidebar

Related Questions

Newbee to Android development. I am developing a application, which have three different tabs.
Having some problems with a site I'm developing for a friend. I've been using
I am newbee with PHP and MySQL and need help... I have two tables
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
Still new to the memory management in iPhone apps, I have a newbee question.
Newbie alert! OK, I have a working central Mercurial repository that I've been working
I'm a newbie to Stack Overflow and I've just started developing an intranet site
With help from StackOverflow today, I have gotten my data layer constructed return data
I am newbee to jquery and have some work assigned to me to complete

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.