Forum Discussion

mindprint_15295's avatar
mindprint_15295
Icon for Nimbostratus rankNimbostratus
May 16, 2014

Serving static web content from a subdoamin

Hi.

 

Situation:

 

Currently the virtual server is serving all files (static and dynamic) with persistent cookies and all files are coming from one domain. For example http://www.example.com/images/logo.jpg or http://www.example.com/css/style.css

 

Goal:

 

Serve the static files from a cookieless domain for example http://images.example.com/logo.jpg this will also benefit the browsers enabling more concurent connections. I have already rewritten all the URLs in html and css files to request from the cookieless subdomains. http://css.example.com/style.css

 

I have already:

 

  • registered the DNS for images.example.com and it resolves ok
  • created a virtual server that will server WITHOUT persistent cookies
  • created a data group like:
    • images.example.com -> /images
    • css.example.com -> /css
  • The www.example.com virtual server uses the pool name main_site_pool

What would the iRule be?

 

3 Replies

  • Indeed. What's an iRule needed for? I don't see why you'd need one. Just use a different pool on the other VS that's serving the image and css files.

     

  • Got it working with following code:

     

    when HTTP_REQUEST {
            set active_pool_name "main_site_pool"
            set actual_host_name "www.example.com"
    
        if {[matchclass [HTTP::host] eq static_content_route_class ]} {
                pool "$active_pool_name"
                HTTP::header replace Host "$actual_host_name"            }
    }

    Is there a better solution?