Varnish: Always server graced "expired" content - caching

I have a question regarding about Varnish serving expired "graced" items. Suppose the following scenario:
My backend takes 5 seconds to generate index.php
I set my beresp ttl to 1 minute
My beresp grace to 1 hour.
When the first client fetches index.php he will be waiting for 5 seconds. Because there's no cached index.php item, the client will wait until the backend server generates the content.
For the following minute, the next clients will not wait at all for index.php, the cached version will be served.
After the minute passes, the following client will wait again 5 seconds. (All subsequent requests in this 5 seconds window will get the cached content due to the 1 hour grace period).
Rather than letting the client wait 5 seconds while the content is generated, is it possible for Varnish to serve the expired (graced) index.php while varnish fetches the new content? This way index.php will be updated always every 1 minute without making the clients wait.
Update
I found this: http://lassekarstensen.wordpress.com/2012/10/11/varnish-trick-serve-stale-content-while-refetching/
Seems a bit ugly to me though.

As far as i know this isn't possible in the current stable version, BUT Varnish 4 will support background fetches. You can find more information about Varnish 4 in the keynote slides of VUG8.

You seem to be right Arjan.
From: https://www.varnish-cache.org/releases/varnish-cache-4.0.0-tp1
Full streaming support, including asynchronous backend fetches. This enables Varnish to serve stale objects while it is fetching or revalidating objects from the backend.

Related

Extend time duration for displaying "PR_CONNECT_RESET_ERROR" error in Mozilla Firefox?

When a site receives high traffic, the tab in Mozilla Firefox stops loading and displays this error message "PR_CONNECT_RESET_ERROR" as shown in screen shot.
What I want is, the tab should continuously keep loading until it receives the response from the site's server without displaying this error or I want to increase the duration(time or number) for which it keeps trying to connect to that site's server by default.
I don't know whether it is possible or not but what I tried is, I changed some of the configurations from about:config. I increased network.http.keep-alive.timeout from 120 to 215 and network.http.max-persistent-connections-per-server from 6 to 20. But I don't find any noticeable change.
Are there better possibilities for achieving my expectations ?
Note: I approximately make 30-40 requests to same url(www.example.com) from different tabs with different sessions.

IE 11 slowness in downloading http response

i am developing an Angular 4 application. One of the HTTP requests returns a large amount of data - approximately 15 MB. I have noticed that downloading that takes more than 20 seconds on IE11 (sometimes more than 35 seconds); whereas on Chrome it happens under 500ms.
I copied the http response to local .json files and tried pointing my code to those.
The result is the same.
Please see attached screenshots.
Moreover, if i debug with Fiddler, I see that Fiddler receives the response nearly 20 seconds before code in IE is invoked. See below. It shows that the alert "mapper invoked" gets called 20 seconds after ClientDoneResponse in Fiddler.
Any idea why IE11 is taking so long whereas Chrome finishes in a few milliseconds?

Session timeout .Net MVC Web config does not work

I have set the web config session timeout to 480 minutes (8hours) I did the same in IIS for the app pool, then for the default website and for my website. Session still times out after 20 minutes, something must be overriding :/
Did anyone have the same problem?
Turns out that I had js script that waited for 20 minutes and then relocated the window to login page...
Obviously I changed the time to longer :)

Session.Timeout not working correctly in ASP Classic / IIS

Recently I created a asp classic web page with which a user can insert his worked hours.
One of the requests was that the page should show a message who is logged in every 10 minutes. The user does his production on a machine and has it's computer besides him, so it is possible that a user will be inactive on the hour web page for 5 - 60 minutes (or even more), yet he will stay on the page nonetheless.
To make the pop up message every 10 minutes I used a timer created in JQuery, this all works fine. Because the total inactive time is not sure, the person wanted the session timeout to be large (24-hours) so that session state (who is logged in) remains for a long time. When a user uses the insert hour web page he is requested to select his username on a different web page and the session("user") is then set.
To accomplish the long session timeout I created a global.asa file in the root with the following code:
<script language="VBScript" runat="Server">
<!-- METADATA
TYPE="typelib"
UUID="00000200-0000-0010-8000-00AA006D2EA4"
-->
Sub Session_OnStart
' Session timeout in minutes (24 hours)
Session.Timeout = 1420
End Sub
</SCRIPT>
Though for some reason (I timed it) the timeout is still the default 20 minutes.. Then I tried to also set the Session.Timeout = 1420 in:
a. The web page of the hours inserting and
b. In the page where the user is selected and the session is being set.
This didn't had any effect though. So then I started researching it and found a similar question on stackoverflow: Session Timeout in Classic ASP website
So this made me look at my IIS settings on the server where I changed a few things.
In the application pool of the website I changed the Regular Time Interval to 0:
Next I also changed the Time-Out to 24 hours in the Session Properties on the Services tab of my website (under Sites):
However this all doesn't have any effect. It still ends the session after 20 minutes (at least it resets my session("user") state.
In the hour inserting web page the session is being checked as follows:
if session("user")="" then
response.redirect("ShowPage.asp?page=SelectUserTimeout")
response.end
end if
So when the session is empty it will redirect to the select a user page where the session("user") will be set again. Though with my time-out settings, if it would actually work, this should only happen after 24 hours and not after 20 minutes.
Any ideas what's going wrong here?
I am using by the way IIS 8.0.
UPDATE
I found the problem! It seems that the Idle Time-Out (Minutes) in the Application Pool of my website was still on the default 20 minutes and for some reason my session.timeout in the asp code didn't override that.
So for anyone facing the same problem I suggest that you go to your Application Pools in IIS --> then go to the application Pool of the website --> go to advanced settings --> Process Model --> and change Idle Time-out
I found the problem myself! It seems that the Idle Time-Out (Minutes) in the Application Pool of my website was still on the default 20 minutes and for some reason my session.timeout in the asp code didn't override that.
So for anyone facing the same problem I suggest that you go to your Application Pools in IIS --> then go to the application Pool of the website --> go to advanced settings --> Process Model --> and change Idle Time-out
In fact the answer posted by the OP is not the solution. I had the same problem and solved configuring the application pool:
Basic Configuration - DO NOT USE .NET CLR. Select No Managed Code.
Pipeline code still Integrated.
Tried on Windows 10 Pro and Windows 2008 server and worked for both.

Keep Accounts Logged In

We have an internal control panel that all employees in the office are logged into all day, including customer service. I'd like for it to be setup so that it keeps you logged in for 1 hour before your session expires. How can I change this in the PHP.ini? I made a change before I understood would keep the session open until the browser window was closed but it didn't stick.
There are two different values you can set:
session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and potentially cleaned up.
and session.cookie_lifetime which is how long the cookie will last.
http://www.php.net/manual/en/session.configuration.php
both values can be set in the php.ini file, but might get overriden in .htaccess files or in your scripts using ini_set.
You can also do this client-side using JavaScript. Use an AJAX call to periodically 'check-in' with the server, keeping the PHP session alive. You can also monitor if the user is doing anything on the current page, show them a '2 minute warning' message, or even redirect them to a 'session terminated' page when the 1 hour inactivity period is reached. You could even use this to 'force' a user to be signed out.
This isn't as secure as doing it purely in PHP, but does give you more flexibility to build cool features.
The most secure place to implement this would be in your application. You can store the session update time in $_SESSION on each page load. Before you update it, you check if it has exceeded the 60 minute limit, in which case you can use session_destroy() to terminate the session, followed by a redirect to the login page (or similar).
I don't think this can be done from the php.ini file. I think you either want to store the login time on the server and compare that with the current time and delete if 60mins have passed, or alternatively, use cookies -- these can have an explicit lifespan. See this for more information on cookies.

Resources