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

  • Home
  • SEARCH
  • 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 980383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:22:21+00:00 2026-05-16T04:22:21+00:00

IGNORE THE QUESTION: The CSS File I was including pulled in the the other

  • 0

IGNORE THE QUESTION:

The CSS File I was including pulled in the the other files hence the correlation *facepalm*


We have the following code for picking a CNAME CDN reference per filename. It must return the same URL everytime based on a given filename. We thought this would be sufficiently random:

<?php

  function cdn_prefix($fileName) {
    $number_of_servers = 4;

    $md5 = md5($fileName);

    $md5 = substr($md5, 0, 4);

    $hash_number = base_convert($md5, 16, 10);

    $server_number = ($hash_number % $number_of_servers) + 1;

    $server_prefix = '//static' . $server_number . '.' . $_SERVER['SERVER_NAME'];

    return $server_prefix . $fileName;
  }

?>

However it seems to favour the number 3:MD5

No matter what I do (salt, different bases, random multiplication, etc) the results headerBg through to mainNavPipe (on the screen shot) all have the same number.

Is there a better algorithm?

EDIT:

Here are the results using same algorithm using a SHA1
SHA1

Everywhere calls the same function – as it returns the whole URL and wouldn’t show the static[1-4] domain unless it when through this function.

The array (for testing) is:

FILES = [
    '/a/files/image/250.jpg',
    '/a/files/image/244.jpg',
    '/a/files/image/247.jpg',
    '/a/css/global/core.css',
    '/a/css/global/print.css',
    '/a/img/global/new_logo.gif',
    '/a/img/global/book-a-free-survey.gif',
    '/a/img/global/make_an_enquiry.gif',
    '/a/img/global/purchase-locks-blue.jpg',
    '/a/files/image/251.jpg',
    '/a/img/global/bg.gif',
    '/a/img/global/headerBg.jpg',
    '/a/img/global/basketBg.gif',
    '/a/img/global/arrow.png',
    '/a/img/global/trolley.gif',
    '/a/img/global/mainNavBg.gif',
    '/a/img/global/mainNavCurrentBg.gif',
    '/a/img/global/mainNavPipe.gif',
    '/a/img/common/sectionNavBg.jpg',
    '/a/img/global/nav_arrow.gif',
    '/a/img/global/footerBg.jpg',
    '/a/img/global/footerCopyrightBg.jpg',
    '/a/img/global/footerLogo.jpg'
]
  • 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-16T04:22:22+00:00Added an answer on May 16, 2026 at 4:22 am

    This was probably a one-time thing or a bug elsewhere.

    function cdn_prefix($fileName) {
        $number_of_servers = 4;
        $md5 = md5($fileName);
        $md5 = substr($md5, 0, 4);
        $hash_number = base_convert($md5, 16, 10);
        $server_number = ($hash_number % $number_of_servers) + 1;
        return $server_number;
    }
    $arr = array(1=>0, 2=>0, 3=>0, 4=>0,);
    for ($i = 1; $i < 200000; $i++) {
        $arr[cdn_prefix("anrg".$i)]++;
    }
    print_r($arr);
    

    gives:

    Array
    (
        [1] => 49770
        [2] => 50090
        [3] => 50026
        [4] => 50113
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some thread-related questions, assuming the following code. Please ignore the possible inefficiency
Sorry guys, it's another CSS height 100% (sortof) question... I have a layout like
Ignore this question, just found a mistake in my code, flag to delete it
Making echo of a question around the web: Is the syntax for svn:ignore patterns
How do I ignore files in Subversion? Also, how do I find files which
How can one ignore Unexpected element situation in JAXB ans still get all other
What is the best SVN Ignore Pattern should TortoiseSVN have for a VB.NET solution?
I have different sites being served up, essentially running off the same code. One
(please ignore this question - it is foolish...) I want something that will do
I'd like to ignore multiple wildcard routes. With asp.net mvc preview 4, they ship

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.