Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Performance and...Performance and...DNN with Rackspace CDN (Akamai)DNN with Rackspace CDN (Akamai)
Previous
 
Next
New Post
9/29/2016 5:23 AM
 
Hi All,

I already have an existing Rackspace account and I use their CDN platform on a number of different web projects. As far as I know the platform is based up the Akamai CDN network/technology but that's the extent of my expertise!

I also manage a couple of DNN deployments and I would really like to be able leverage the Rackspace CDN for these sites. Is it possible to use the Rackspace CDN with DNN and how would I go about configuring this? I tried to Google it but I could not find any information.

Any help/advice would be much appreciated.

Cheers,

Olly
 
New Post
9/29/2016 10:51 AM
 
you may use rackspace to deliver files being used on your site (images, JavaScript, CSS and documents)

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
9/29/2016 11:56 AM
 

FYI I have ended up creating a code solution to this as an HTTPModule. It won't be good for everyone but seems to be doing the job for us.

CDNModule.cs:


 public class CDNModule : IHttpModule

    {

        void IHttpModule.Dispose()

        {

        }


        void IHttpModule.Init(HttpApplication context)

        {                

            context.ReleaseRequestState += new EventHandler(context_ReleaseRequestState);

        }


        void context_ReleaseRequestState(object sender, EventArgs e)

        {   

            //Since it's DNN all requests (for pages!) will come in via the default.aspx handler so we only want to do this when we are processing web pages

            //If this handler runs on other files types (like images for example) then we get in all kinds of trouble 

            if (HttpContext.Current.Handler != null && HttpContext.Current.Handler.GetType().FullName == "ASP.default_aspx")

                    HttpContext.Current.Response.Filter = new CdnFilter(HttpContext.Current.Response.Filter);

        }

    }


    /// <summary>

    /// Works on UTF-8 text/html requests only and will bork any other requests you attempt to put through it

    /// </summary>

    public class CdnFilter : MemoryStream

    {

        private readonly Stream _outputStream;

        public CdnFilter(Stream outputStream)

        {

            _outputStream = outputStream;

        }


        public override void Write(byte[] buffer, int offset, int count)

        {

            var contentInBuffer = Encoding.UTF8.GetString(buffer);

            string CDNUrl = ConfigurationManager.AppSettings["CDNUrl"];

            if (CDNUrl.EndsWith("/"))

                CDNUrl = CDNUrl.Substring(0, CDNUrl.Length - 1);


            if (string.IsNullOrEmpty(CDNUrl) == false)

            {

                foreach (Match match in Regex.Matches(contentInBuffer,

@"(?:\<img|\<Img|\<IMG)(?:(?!\>).)*(?:src|Src|SRC)\=(?:'|"")((?!['""]).)*(?:'|"")" + "|" +

@"(?:\<link|\<Link|\<LINK)(?:(?!\>).)*(?:href|Href|HREF)\=(?:'|"")((?!['""]).)*(?:'|"")" + "|" +

@"(?:\<script|\<Script|\<SCRIPT)(?:(?!\>).)*(?:src|Src|SRC)\=(?:'|"")((?!['""]).)*(?:'|"")", RegexOptions.Compiled))

                {

                    string source = "";

                    CaptureCollection caps = match.Groups[1].Captures;

                    if (caps.Count == 0)

                        caps = match.Groups[2].Captures;

                    if (caps.Count == 0)

                        caps = match.Groups[3].Captures;

                    if (caps.Count == 0)

                        continue;


                    foreach (Capture c in caps) source += c.Value;

                    string replace = source;


                    if (replace.StartsWith("//"))

                        replace = replace.Substring(1);


                    if (source.StartsWith("/") || source.StartsWith("//"))

                    {

                        //do twice for each type of quote (we want to match on the quotes to stop repeated replacements)

                        contentInBuffer = contentInBuffer.Replace("=\"" + source, "=\"" + CDNUrl + replace);

                        contentInBuffer = contentInBuffer.Replace("='" + source, "='" + CDNUrl + replace);

                    }

                }

            }


            _outputStream.Write(Encoding.UTF8.GetBytes(contentInBuffer), offset, Encoding.UTF8.GetByteCount(contentInBuffer));

        }

 

    }

 

Web.config:

<system.webServer>

      ....

    <modules>

      <add name="CDNModule" type="Your.Namespace.Here.CDNModule, YourAssemblyName" />


 
New Post
9/29/2016 2:13 PM
 
thanks for sharing your solution!

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Performance and...Performance and...DNN with Rackspace CDN (Akamai)DNN with Rackspace CDN (Akamai)


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out