Need some help to setup my page

hello, I have a page currently that looks like mysite.com/file.php?bla=bla

if my site is down, can I somehow use Cloudflare to show mysite.com/file2.php? so I only need file.php?bla=bla if the site is up, but if it’s down I only want to show file2.php

thank you

Are you talking about something like a maintenance page?

If your site is down due to a server, network or whatever issue, well… then it’s down. A redirect to a page to the same origin would be useless.

Hi, hmm I thought Cloudflare could deliver content even if my site is down? it’s not for viewing by people, it’s maybe like an API I guess, and I would need it to deliver some information if possible, but without all the database code etc that is run if the site is up, so if I could make the Cloudflare page deliver a cached version of another file?

Sure they do.

But what I am not sure about is if they cache it the way you want:

Cloudflare doesn’t cache every page on your site. A limited cache of your site will be displayed. Specifically, Always Online will cache the first 10 links from your root HTML, then just the first links from each of those pages, and finally the first links from each of those subsequent pages. This means that only some pages on your site will be viewable when your origin server goes down.

Maybe @cs-cf has a bit more input for you

hmm but is it not possible to configure it so that a specific page shows a specific cached page if it’s down? I only need Cloudflare active for a specific page, if my site is down, I would like it if it displayed a cached version of Another page(file), I don’t need any of the other pages to work, so bla.php shows data based on ?bla=input, if site is down, I would like bla2.php to show static content

Well. Maybe you can achieve this with a page rule and add two settings:
Always Online and
Cache Level -> Cache Everything.

Could be worth a try.

CAUTION: Cache-everything means all visitors will receive the cached asset therefore Cloudflare does not recommend setting this on assets requiring authentication or other dynamic dependencies.

thank you for your response,
I only have Cache Level > No Query String, Ignore Query String, Standard

however it’s ok for now because my webhost is going to do maintenance so I can edit my files to display the static content I need them to display, but how can I test this? I edited so my bla.php will always show the same content regardless of parameters(and I will just undo this change when my host is done), so if a request is made to bla.php?blabla=bla, will this display my static content now? I don’t know how to test it, I purged all cached files

I can edit my files and it’s in my browser showing the output properly right now, will Cloudflare show me this if my host is down?

thank you again

to add on this, I have never experienced my site being cached by Cloudflare, all edits are shown right away, but I have set nameservers to Cloudflares nameservers etc

and to add on that I tried https://checkforCloudflare.selesti.com/ and it does say I’m using it, so I cleared cache and it’s set to Always On, does this mean www.mysite.com/bla.php will show a cached version of that if my host is down? (I never noticed this before, even if I have had Always On since 2 years when I set up my domain), not sure if I’m missing some other setting

It depends on why your site is down.
You can set up custom error pages on your server. For each error type you can point to what file you want shown. For example if PHP choked you can have apache/iis serve 5xx.html. But if it were apache that died, you’re SOL there.

okay so there is no way if my host is down, that Cloudflare could show some content of my choice? without any like “this is a cached version” etc

As far as I know, if your host goes down, CF will pass the error along to the user. Meaning, in order for Always Online to work, your host has to give CF a standard error code. Your host has to be working.

https://support.cloudflare.com/hc/en-us/articles/202238800
“In order to trigger Always Online, your web server will need to be returning a standard HTTP Error code of 502 or 504 timeout. Always Online will also work when we encounter issues contacting your origin (Cloudflare Errors 521 & 523), timeouts (522 & 524), SSL errors (525 & 526) or an unknown error (520). Always Online will not be triggered for other HTTP response codes, such as 404s, 500, 503, database connection errors, internal server error, or empty replies from server.”

If your domain is on a paid plan, you can customize CF’s error pages:
https://support.cloudflare.com/hc/en-us/articles/200172706-How-do-I-customize-Cloudflare-error-pages-

I suspect that Cloudflare Workers could be implemented to respond to specific Site Down errors with a redirect or something.

I’m pretty clueless with Javascript, but from what I’ve seen, it’s pretty powerful when used in the Workers framework.

Thank you for your reply, actually I might be a bit slow with this - if my host were to do maintenance, I assume some type of error would be returned when it times out? It’s not “page not found”? if so, maybe I could customize the error page to display specific text if it is down

It depends. Some hosts might send out the error with a 200 code. Some might use 500. You’ll have to fiddle around to find out.

If your domain is on a paid plan, you can customize CF’s error pages. Have you looked into this?
https://support.cloudflare.com/hc/en-us/articles/200172706-How-do-I-customize-Cloudflare-error-pages-

hmm but could I not use Always Online, if my host is unreachable, Always Online would simply display a cached version? I don’t see what else is the point of Always Online? am I misunderstanding something or why do I need to edit error pages for this

According to Jules’ response earlier, a “typical” offline error code will trigger Always Online, but some hosts don’t use the codes that will trigger this.

I use Always Online, and it’s kicked in a time or two in the past. It does return a 503, so my uptime monitors alert me, but visitors see a cached version of my page with an Offline message at the top.

hmm okay, my most visited page file is the one I also need cached (I saw it said it caches the most visited ones), however in my case it’s not actually people visiting that page but it’s scripts contacting it, so I would need to show a static output (that basically allows the script to function, if page is down = cant function), but I assume the html code from the offline message would mess that up anyway :confused:

This topic was automatically closed after 14 days. New replies are no longer allowed.