module YARD::Server::StaticCaching

def check_static_cache

Other tags:
    See: Commands::Base#cache -

Returns:
  • (nil) - if no cache is available and routing should continue
  • (Array(Numeric,Hash,Array)) - the Rack-style response

Other tags:
    Example: Implementing In-Memory Cache Checking -
def check_static_cache
  return nil unless adapter.document_root
  cache_path = File.join(adapter.document_root, request.path.sub(/\.html$/, '') + '.html')
  cache_path = cache_path.sub(%r{/\.html$}, '.html')
  if File.file?(cache_path)
    log.debug "Loading cache from disk: #{cache_path}"
    return [200, {'Content-Type' => 'text/html'}, [File.read_binary(cache_path)]]
  end
  nil
end