How to wait long enough for Django views results on Firefox? - django

I'm developing a website with Django 2.2, using :
Centos 7
Mozilla Firefox 60.6.0
Google Chrome 73.0.3683.86
Docker and Docker compose
The first page allows the user to submit data from a formatted file (equivalent to csv) and the second page shows the result of calculations (done row by row) in a datatable.
I have noticed a difference between Mozilla Firefox and Google Chrome:
For big files, on Chrome, the web browser waits long enough to receive and display the results of calculations. Whereas in Firefox, the web browser stops waiting for localhost and the "results" page is not loaded.
As the problem occured when the file exceeded a certain size, I have guessed that the app spent too much calculating time and Firefox stopped waiting for the response before to load the "results" page.
So I changed my view to accelerate calculations. The problem still persists with big files. With files from approximately 3.5Mo the results page os displayed or not (almost randomly).
I tried to raise "dom.max_script_run_time" in my Mozilla settings but this can't be done programatically.
I saw that Celery can be used for long time running calculations, but in my case, calculations can be performed on 1 or 3000 rows. I would like to find a solution without using Celery.
Another solution could be to use JavaScript to set a timeout when Firefox is detected as web browser, the to add a error message, I also would like to avoid this.
I expect my app to work well at least on Mozilla Firefox, Safari, Opera and Google Chrome Web browsers.
Thanks for your help !

Related

Django will run the function content twice when using render

I am sorry that my English is not good. My problem is that refreshing the page in Google Chrome will cause the function with render to run twice But run it once in the Firefox browser. I don't know if this is a problem with Google Chrome or something else?(I hope to get help, thank you)
def add_teacher(request):
Teacher.objects.create(username='zhangs',avatar='https://static-image.xfz.cn/11.jpg',jobtitle='a',profile='b')
print('==')
return render(request,'course/course_index.html')
Both Google and Firefox run the same content.
Two teachers' data will be created when Google Chrome refreshes the page, But only one piece of data is created when Firefox is running. Pycharm will also print two ‘==’ content when Google runs. Print one on Firefox.

Prerender.io first hit missed

I installed prerender.io with Nginx on my Ember.js project.I use the Facebook debugger to check if the prerender is installed correctly. The problem:
Each first hit of the prerender is a fail. Unfortunately, Facebook caches this version, so it is the one that is displayed on the site.
When I ask "Fetch new scrape informations", I get a hit and the content is displayed properly.
How can I make the first try a hit?
GUESSES
Maybe there is a problem with window.prerenderReady, that is used in my project (ember-prerender)?
Maybe the Nginx configuration does not wait for the result of the caching, or the caching is too long?
INFOS
I use Nginx with the standard configuration recommended by prerender.io
Facebook can timeout if the response takes longer than 5 seconds. It sounds like your pages are taking 5+ seconds to render when being rendered on the fly. The reason it works the second time is because the page is cached at that point and returned in < 100ms.
I'd suggest trying to speed up your page loading time so that pages rendered on the fly are returned more quickly. Send and email to support#prerender.io if you want some help there! We can send you the timings of requests being made on your URLs.

ColdFusion pages hang, but only after loading content

We have a Windows server running ColdFusion 8. When I load a CF page from that server in a browser, the page content is displayed almost immediately, but the connection does not close. The browser's "page loading" icon keeps spinning for another ten seconds.
I did a test where I created two files: test.cfm and test.html and loaded them side by side on the server. Each file contains only a single line of text: "This is a test." When I load each page in a browser, both pages display the text immediately, but only the CF page keeps "loading" for another ten seconds.
This behavior is making our AJAX-driven pages unusable. What is causing this behavior, and how I can fix it?
There must be some code in there trying to do something. And it may not be in the page itself, it could be in an include or the application file.
That type of spinning cursor behaviour sounds like some sort of ajax call failing after the initial page load.
One thing that would help is to turn on ColdFusion debugging and post the results here.
ColdFusion and Ajax, out of the box work very well together, and ColdFusion has an almost insanely simple page debugging tool that make it extremely easy to see the execution path of the CFM file and where the page is spending its time.
Have you restarted the CF service? If there are already hung requests or other problems then that will likely be the only way to resolve.

Django dev server slowness with chrome + other instance / browser

First let me say that this is not about production settings for django - it's for local development and testing.
I'm testing out multiple user scenarios, requiring I log in as several different users. I'm logged in as user A using Chrome, and user B using Chrome's incognito mode, and as user C using Firefox. I'm using "manage.py runserver" to run the dev server.
The first instance with regular Chrome (user A) works well and is fast. The other instances are very slow - perhaps better described as stuck. They sit around doing nothing for 10-30 seconds, and then finally display the page fairly quickly.
While the other browsers are stuck I can go to the first one (user A) and click around and it works well and is fast. In other words only the requests from the other two instances get stuck - the first instance always works well.
The resource that's slow appears to be the html page, not the static content.
The backend is Django 1.1.1 with SQLite as the database running on OS X 1.6.7 .
Any ideas? Is Chrome doing something special to hog the connection?
This could be a known issue "Development web server sometimes hangs with Chrome":
https://code.djangoproject.com/ticket/16099
It is fixed recenty in django trunk:
https://code.djangoproject.com/changeset/16427

Django/IE8 Admin Interface Weirdness

Esteemed Django experts and users:
I have been using Django's admin interface for some data editing needs. I am using it on Windows Server 2008, and using django-mssql to connect to a SQL Server backend. Python 2.6.2 Django 1.1.0 final 0
As per usual w/ Django, this was fairly easy to set up, and works beautifully on Firefox, but using IE8 I intermittently get a puzzling 'Internet Explorer cannot display this webpage' when I save a record.
In the log, looks like typically on a save there's a POST request that returns a 302 status followed by a GET returning a lovely 200. This is on Firefox. On IE8 looks like sometimes POST works but GET doesn't.
So that's what I have going on. Any help w/ this will be appreciated. Thank you.
I suspect the bug is within IE8's refusal to process the redirect properly.
The 302 POST pushes to browser to the 200 GET, but if the browser never processes the 302 then the Django (or the server) will not log a 200 GET because the browser never opened the page (the server can only log what is accessed, ergo the browser is not making the call).
If you have Django behind something (IIS using FastCGI, or Apache, or something), bump up the logs to make sure there's no silent error in rendering. I had the same problem on Vista x64 Ultimate IE8 Beta 2, but compatibility mode appeared to fix the problem somewhat -- there was still some intermittently occurring refusal to redirect.
I realize this post is a bit old now, but I had the exact same symptoms recently. After a lot of digging around, I found that IE8 has issues accepting cookies with a life of less than 20 minutes.
In our Django project's settings.py we had the property SESSION_COOKIE_AGE set to 10 minutes. Once I bumped it to 20 minutes, IE8 had no problems logging in.