-
-
Save noahlarsen/6184822 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# it's not critical for understanding | |
# but here is the associated server-side action | |
# | |
def version | |
@program = load_program! | |
@version = @program.versions.find(params[:version_id]) | |
if stale?(:last_modified => @version.updated_at, :etag => @version.cache_key) | |
render | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// today's quiz is simple: | |
// | |
// fork this code and explain, in english, what it does. | |
// | |
// suggest simpler alternatives. | |
// | |
// Check on state. If not complete... | |
if(state != 'complete'){ | |
var get = function(){ | |
jq.ajax({ | |
'type' : 'GET', | |
'url' : url, | |
'cache' : false, | |
// I don't know what this is doing. Saving current page html into version variable? | |
'success' : function(html){ | |
version.replaceWith(html); | |
} | |
}); | |
}; | |
var head = function(callback){ | |
jq.ajax({ | |
'type' : 'HEAD', | |
'url' : url, | |
'success' : function(res, code, xhr){ | |
var server_last_modified = xhr.getResponseHeader("Last-Modified"); | |
//Compare Server last modified to page last modified. Run until matched. | |
if(Date.parse(server_last_modified) > Date.parse(last_modified)){ | |
callback(); | |
}; | |
} | |
}); | |
}; | |
//Get header info | |
head(get); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment