0

I have a web service where any user can start a process that takes somewhere between 15 seconds and 10 minutes to complete. The process is started with a POST request and the user is redirected to page that shows current progress of the process (e.g. https://example.com/progress-status/123).

My current implementation is to send HTTP header Refresh with value n;url=https://example.com/progress-status/123 where n is automatically changed between 5 and 120 according to expected time to completion and current server load. As a result, the progress status is automatically updated once every 5 seconds or more. After the progress has been completed, the status page will immediately redirect (HTTP 301 and Location header) to the completed job.

This works otherwise nicely but causes ugly flickering in Opera 42.0, which considers this to mean forced reload and skip all caches. I'm sending correct Cache-Control headers so using cached result for everything would be fine but Refresh header causes all caches to be ignored. (The status page contains some images and links to static CSS files so it does not make any sense to refresh those resources for every poll request.)

Is there any way to implement polling just the HTML page without JavaScript? I know that I could poll just the current status with Ajax query and then update the part of the currently visible page with the updated information. However, that will not work if user disables JavaScript. Rest of the service works without JavaScript so requiring JavaScript for something this simple seems bad. (I already have a GET submit button on the progress status page to force refresh manually.)

I know that HTTP Refresh header is not defined in HTTP 1.0 or HTTP 1.1 so this is a bit grey area. I'm looking for something that works in real world without JavaScript.

Mikko Rantalainen
  • 14,132
  • 10
  • 74
  • 112
  • 4
    The HTTP protocol is stateless by design. So if you cannot use javascript for this, then I am afraid that you will have to live with it because the protocol has nothing to offer you. Besides, I see it perfectly normal that the user experience degrades if javascript is disabled. And I stress on the word **degrade** which is different than the word **break**. – Darin Dimitrov Jan 24 '17 at 16:48
  • 2
    Does opera exhibit the same behaviour with a `` element in the head as opposed to a header? - A bare-bones page can always be delivered via an IFRAME. – Alex K. Jan 24 '17 at 16:49

3 Answers3

1

you can try the html meta refresh

<meta http-equiv="refresh" content="5"><!-- reloads the page after 5 seconds //-->

W3Schools doc on <meta>

Of course only put it if progress is < 100% :)

Boris
  • 1,161
  • 9
  • 20
-1

I can't think of any way to do that. And much less one that entails good practices: use Javascript.

You can use a noscript tag to advise your users that JavaScript is necessary:

<noscript>
    <h1>JavaScript is not enabled, please check your browser settings.</h1>
</noscript>

Realistically almost everyone has Javascript enabled nowdays.

Works Google Maps, FaceBook, etc, without JavaScript? No.

Why your web app will require that?


I complete agree with this phrase from @Matthew Trow answer:

I think sacrificing functionality for 99% of users to accommodate 1% is sheer bloody mindedness.

Community
  • 1
  • 1
tomloprod
  • 7,472
  • 6
  • 48
  • 66
  • Downvote because this is not answering the question. Your assumptions about usage context are not what was asked about. – Florian Ledermann Mar 05 '21 at 09:26
  • @FlorianLedermann I do not agree with the downvote, since I believe that I do respond to the user; it is not possible to do so. And my additional comments are recommendations that I give. However, everyone has their opinion and is respectable. – tomloprod Mar 05 '21 at 09:41
  • Web is a well-designed solution to caching and IA content access. Absolutely all modern client-side "SPA" web frameworks do overthink it by 100x of complexity, because now you got router, caches, stores, fetches, refresh loading indicators, and absolutely horrible user experience, because it costs (in term of dev time) more to use JavaScript on client side than to not. Try it. It's called Web. It's very well thought, and browsers are optimized for that. PHP, Python, Node.js, Perl, Swift, Rust, C++ are all suited to make a complex website (with the help of an SQL server indeed). – Brian Cannard Feb 11 '22 at 03:08
  • @BrianCannard Did you understand the question that Mikko Rantalainen asked? Did you understand my answer? – tomloprod Feb 11 '22 at 08:55
  • @tomloprod "without JavaScript" means `meta http-equiv="refresh"` not `noscript`. Your answer not even wrong, because you're answering the wrong question. – Brian Cannard Feb 11 '22 at 09:49
  • @tomloprod plus, your answer is also politically polarized, and violates some of community rules on StackOverflow. – Brian Cannard Feb 11 '22 at 09:50
-1

Not completely without, but you don't have to reload the whole page. Instead of that, you could just listen to SSE (server side events) and update the status value on the page (the element where it is contained).

shaedrich
  • 5,457
  • 3
  • 26
  • 42