How to enable CDN for a subdomain with external web server? - cdn

My landing page is a static built website on Netlify.
Then I have a subdomain, which is an A record in DNS (set in Netlify).
This subdomain is points to an external web server (nginx+Django), which provides REST API and serves static content.
The question is how can I make this subdomain to use Netlify's CDN, when serving static content from Django API?
Are there any approaches to do it?
Netlify advises against using any CDN in front of it, as it already provides CDN. As well as there'll be a problem with SSL certificate.
I tried my best to look for such a question, but I couldn’t pick the right terms, I suppose, so I didn’t find it.
I would be very grateful for any advice!
Thank you and best regards!

You can use Netlify's Proxy Rewrites: https://docs.netlify.com/routing/redirects/rewrites-proxies/ to add some level of CDN to your site. However, it will totally be upto Netlify to decide how much time your content will stay in cache. If it's not in Netlify's cache, there won't be much of a performance boost by doing this - so I'd advise against it, unless absolutely necessary.

Related

How can i create a custom CSS for a website hosted on Cloudflare

I want to make a website hosted on Cloudflare more beautiful by adding more css style to it and correcting some layout of some pages that are not good enough.
The challenges i'm having is that i don't know where to start, I logged into the cloudflare settings, theme settings but i didn't see the css of the pages i want to correct. I tried googling it and i couldn't find much help, I only notices that i can add CSS through Add CSS app but i don't know where or how.
Please help me with a link to something to read on how to customize cloudflare pages or tell me how to start it please.
Since you mentioned the website is hosted on Cloudflare, I'm assuming it's on Cloudflare Pages. You can't edit CSS through Cloudflare. Your code will be in either Github or Gitlab connected with your Pages project. Once you find your code repo, then only you can edit. Any changes should be updated on your Pages.
If your website is not on Pages, then it is on a web server hosted somewhere else. You'll need access to the server in order to make any changes. See the DNS records of your website's domain to find the IP of the server if you're not sure where it is hosted.

Serve static assets with an efficient cache policy

Help needed!
I am struggling setting the cache policy on my wordpress website.
I have tried to set the expirations manually in .htaccess and I have tried several plugins.
Nevertheless Google Page Speed Insights keeps displaying the message "Serve static assets with an efficient cache policy".
Is it possible to sort of manually add a cache policy (e.g. via .htaccess) for a specific line in Google Page Speed Insights?
Any help or suggestions will be much appreciated!
"Serve static assets with an efficient cache policy".
Most likely you are getting this message for resources which are not hosted by your website and is coming from external sites such as Google Analytics code or any other third party code. If that is the case you won't be able to do much and you can simply skip the "Serve static assets with an efficient cache policy" suggestion.
If the suggestion is for your own hosted content and you are not able to resolve even after making changes to .htacces files the problem could be in your web hosting and you need to contact them for resolution.

How to proxy a rails app in heroku with a WP blog under same domain

I have this:
A rails app on Heroku that servers mydomain.com
A WP site on another hosting (that I can move to AWS .. or even heroku)
I need that mydomain.com/blog serves the WP installation, I DONT want it to be a subdomain for SEO.
My first idea was setup apache / nginx as reverse proxy on a instance on AWS. However I worried that this setup is not optimal as backends are in different services.
It's possible to setup heroku dyno as a proxy? I understand there is no way to modify the system files on heroku, like create a custom nginx setup to do the proxy. I was wondering if there is some application that works as a proxy and can be installed in heroku, next setup the blog in heroku also.
Or it's a good idea to setup an AWS instance as proxy in the same region that the heroku is (us-west1), and setup the blog also there.
I'm interested in the pros and cons of each solution and what would be the best way to go.
I had tackled the same exact problem with Rails and WP for quite some time.
My configuration and result:
Rails app is hosted on heroku (www.sexycrets.com)
WP Blog is hosted on another server (blog.sexycrets.com)
When the browser requests www.sexycrets.com/blog he receives the same html page that he would have received if browsing blog.sexycrets.com and the url on the browser remains the same
How I achieved it
One solution that does works well for SEO is to use a gem as reverse proxy (I use drewwed/rack-reverse-proxy from Github). You can configure it to intercept the route "/blog" (and "/blog/") so that every time Rails is asked for /blog it loads your WP site with a backend call and returns it to the user. This is a completely transparent operation from the user browser perspective, aside from the delay introduced. The user browser has no way to know that the blog page returned in the response was loaded from another server, the url on the browser remains "www.sexycrets.com/blog".
Pros: SEO requirements are satisfied
Cons: Performance since the reverse proxy is not very performant in terms of delay introduced
Alternative
For sake of completeness the other option I tried was to use an iFrame in a static page hosted on heroku that loads the WP. The problem is that in order for it to work avoiding a circular reference all the links in the WP blog have to point to blog.sexycret.com (not www.sexycrets.com/blog) which partly defeats the SEO purpose.
Pros: Performance is very good since it is not even using Rails: the user browser loads the static /public/blog/index.html page that contains just the iFrame that points to the WP blog
Cons: the links in the blog are not pointing to the main domain but to the 3rd level domain defeating
Hope this helps!

Host complete WordPress website in Amazon CloudFront or any other CDN

What I would like to do
According to a Amazon Senior Architect to whom I spoke recently, it is possible to cache dynamic website content in Amazon CloudFront.
The way I understand how this could work, is that in addition to doing a page cache of each page which has been accessed, cache the page in CloudFront too.
What I have tried
I have experimented a lot with W3 Total Cache and its settings but did not find a solution to this problem. I also have tried to set up CloudFront directly in the AWS control panel but did not find a way to cache the static result (html?) of WordPress's php calls.
Question
How would you tackle the issue?
How can I cache a static version of WordPress's dynamic pages in CloudFront or any other CDN?
Here is a concept plugin which aims to do this:
https://github.com/PeterBooker/wp-cloudfront-helper
most CDNs advertise that they can cache dynamic web sites. Unless they have very specific information about the pages they need to serve, they can't. There are situations where the "penalty" of a CDN for a dynamic page isn't that bad, but having an additional hop in-between the web server and the end user can only be faster in some very specific situations. The main reason is the absense of a Last-Modified header for the generated pages.
From my experience working with (at) CDN providers, the most performant way to include a CDN is to use a different hostname for the static assets and point that hostname to the CDN with your web server as the origin server.
Jan

SSL and relative URLs in site links and redirections

I have been working on a website in beta phase for some time now, and am finally about to launch it. There are several links, anchor tags, with relative URLs throughout the site that link to the admin and cart sections of the website, and now they have to be SSL secured.
Also, same question for relative URLs in Response.Redirect("~/../..");
When a user is browsing over http, is there anyway to redirect them to a page with https connection using a relative URL? It seems like poor practice to code absolute URLs for links and redirections for the purpose of SSL. If the domain name changes, I have to rewrite them all. Plus, if I want them to work on my localhost, I would have to change them every time I upload to server. There must be some solution.
Switching Between HTTP and HTTPS Automatically is a very good code to use for the implementation of switching logic fast and easy - and not change your existing code.
Similar: Preparing my ASP.NET / MVC site to use SSL?
These helper methods by Rick Strahl will help you
http://www.west-wind.com/weblog/posts/2007/Sep/18/ResolveUrl-without-Page
Pay special attention to ResolveServerUrl.
Depending on what version of IIS you are running, you could always offload this functionality to the webserver. Check out the URL Rewrite module here.

Resources