No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
.gitignore
CODE_OF_CONDUCT.md
Gemfile
LICENSE.txt
README.md
Rakefile
api-response-cache.gemspec

README.md

API Response Cache

Improve rails server api response time by caching your rails api response response data to client side.

Installation

Add to Gemfile

gem 'api-response-cache'

Then run

bundle install

Configuration

If you want to change config create file at config/initializers/api_response_cache.rb

ApiResponseCache.configure do |config|
  config.refresh_by_request_params = false  # true to saperate cache by request params
  config.cache_by_headers = ['header-key']  # optional this need when saperate cache with header only
end

Basic Usage

class ExamplesController < ActionController::API
  cache_response_for :index

  def index
    # ... your code here
  end
end

Add expire duration

cache_response_for :index, expires_in: 1.day

Clear Cache

ApiResponseCache.clear

TO DO

  • Block check in contoller
  • Block check in config