New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
CDN Cache Status
So I tried building my own 3 continent CDN but not able figure out the cache status header.
How can I add CDN-Cache status header to this config? -http://pastebin.com/bbi9Z5p4
I tried adding the below header but it is not working
X-CDN-Cache-Status $upstream_cache_status;
Comments
I forgot why exactly, but we do this:
@BunnySpeed said:
>
I know you don't do that, because it's wrong. You'd likely do a test, rather than an assign.
I like abusing ternary (when it works, it works!).
more_set_headers (($http_cache_status == 'HIT') ? 'CDN-Cache: HIT' : 'CDN-Cache: '.$upstream_cache_status);
It's nginx. Pretty sure that's working.
I use mirror servers, it will definitely 1000% hit, and will stay forever in edge servers even it never ever accessed
No need of cache status
He is referring to this:
if ($http_cache_status = 'HIT') {
should be
if ($http_cache_status == 'HIT') {
$upstream_cache_status: keeps the status of accessing a response cache (0.8.3). The status can be either “MISS”, “BYPASS”, “EXPIRED”, “STALE”, “UPDATING”, “REVALIDATED”, or “HIT”.
You just need to add more_set_headers CDN-Cache $upstream_cache_status;
The code that you posted does not work on nginx.
I posted a working solution, you're correcting me with a broken one lol
Try it. Nginx throws: unexpected "==" in condition in /etc/....
EDIT: I also remembered why we use more_set_headers. You should probably use the normal add_header, I just used this because it needed to override the already existing header.
It's because nginx pragmatically does it wrong.
= generally means "assign this to variable" not "does this equal that"?
Or pattern matching
Ok ok, I will show myself out now. Bye, bye, C.
I'm hereby forcing you to use nothing but m4 and [BrainF$#%*] (https://en.wikipedia.org/wiki/Brainfuck) for the rest of your career. Smartass.
@BunnySpeed @didtav The CDN is passing every request to the origin server even though static resources are cached in the CDN. What wrong am I doing here?
Here is the nginx config - http://pastebin.com/bbi9Z5p4
First, if you're making a CDN, you're probably looking to use proxy_cache instead of proxy_store.
Second, you might want to try to follow a tutorial explaining how to do this from scratch. You could try following something like this:
https://mattgadient.com/2014/01/28/making-your-own-cdn-edge-cache-on-the-cheap/
I haven't actually read the whole article, but it seems to explain things in detail.
we are on a different pathway, bro.
I'm using a really really simple method to get my cdn work, the only software I installed on the edge server is nginx optimized to serve static content and then use rsync to automatically mirror my main server to all edge servers.
multiple servers > rsync > GeoDNS > done
I don't use nginx to proxy any request