Module: YARD::Server::StaticCaching

Included in:
Router
Defined in:
lib/yard/server/static_caching.rb

Overview

Since:

  • 0.6.0

Instance Method Summary collapse

Instance Method Details

#check_static_cacheObject

Since:

  • 0.6.0



4
5
6
7
8
9
10
11
12
13
# File 'lib/yard/server/static_caching.rb', line 4

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