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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:20:40+00:00 2026-05-20T06:20:40+00:00

I’m optimizing our webpage, and we have notice something we want to dramatically improve.

  • 0

I’m optimizing our webpage, and we have notice something we want to dramatically improve. We use Symfony 1.3.

When the user loads example.com, the filters (rendering, security and remember) are executed. Then we execute our subdomain filter. If it’s the first time the user is here, we get the preferred language of his browser and we redirect the webpage to en.example.com or es.example.com. If the user has a session, we get the language from its session; and we redirect to the subdomain. Then the en.example.com page loads again.

We lose around 1.5 seconds on that redirect. The en.example.com loads sometimes faster than that. How we can get rid of that delay? Changing the index.php and doing the browser-memcache-or-db queries directly without loading symfony?

thanks a lot!

  • 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-20T06:20:41+00:00Added an answer on May 20, 2026 at 6:20 am

    I finally made the redirection on index.php. From 1 to 1.5 seconds to 40ms. Something like:

    <?php
    
    $host = $_SERVER['HTTP_HOST'];
    $host_a = explode('.', $host);
    
    // if subdomain is not in the supported langs
    $langs = array('en', 'es');
    if( !in_array($host_a[0], $langs) ){
    
      // try to get the cookie and the user culture
      $cookie = $_COOKIE['symfony'];
      list($id, $signature) = explode(':', $cookie, 2);
      if( $signature == sha1($id.':'.'secret_cookie') )
      {
        // get cookie data from memcache
        $memcache_obj = memcache_connect('localhost', 11211);
    
        // the cookie is built with two parts separated by :
        // - md5 of the sfCache directory
        // - $id from the user
        $md5_dir = md5(dirname(dirname(dirname(__FILE__)).'/lib/vendor/symfony/lib/cache/sfCache.class.php'));
        $session = memcache_get($memcache_obj, $md5_dir.':'.$id);
        $user_lang = $session['symfony/user/sfUser/culture'];
        if( !in_array($user_lang, $langs) ) $user_lang = 'en';
    
      // if not, get browser lang
      }else{
        $user_lang = prefered_language($langs);
      }
    
      // build url
      $url = 'http://'.$user_lang.'.'.str_replace('www.', '', $_SERVER['HTTP_HOST']).$_SERVER['REQUEST_URI'];
    
      // and redirect
      Header( "HTTP/1.1 301 Moved Permanently" );
      Header( "Location: ".$url);
      die();
    }
    
    require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
    
    $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
    sfContext::createInstance($configuration)->dispatch();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.