{"id":15508368,"url":"https://github.com/yeah/page_cache_fu","last_synced_at":"2025-07-22T15:36:31.664Z","repository":{"id":662178,"uuid":"305154","full_name":"yeah/page_cache_fu","owner":"yeah","description":"PageCacheFu adds the following missing features to Rails page caching: expiry time for cached pages, different caches for different hostnames (e.g. subdomains), and different caches for query strings.","archived":false,"fork":false,"pushed_at":"2009-12-18T22:05:51.000Z","size":93,"stargazers_count":19,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T17:24:46.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rocket-rentals.de","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yeah.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-09-12T17:16:33.000Z","updated_at":"2019-08-13T14:28:03.000Z","dependencies_parsed_at":"2022-08-16T10:35:23.982Z","dependency_job_id":null,"html_url":"https://github.com/yeah/page_cache_fu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeah%2Fpage_cache_fu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeah%2Fpage_cache_fu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeah%2Fpage_cache_fu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeah%2Fpage_cache_fu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeah","download_url":"https://codeload.github.com/yeah/page_cache_fu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245052661,"owners_count":20553162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T09:38:04.635Z","updated_at":"2025-03-23T03:33:15.674Z","avatar_url":"https://github.com/yeah.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= PageCacheFu\n\nPageCacheFu adds the following missing features:\n\n* Expiry time for cached pages (using \u003ccode\u003e:expires_in\u003c/code\u003e option)\n* Different caches for different hostnames (e.g. subdomains)\n* Different caches for query strings\n\n== Installation\n\n* Just install the plugin like so:\n\n    ruby script/plugin install git://github.com/yeah/page_cache_fu.git\n\n* Add something like \u003ccode\u003e:expires_in =\u003e 30.minutes\u003c/code\u003e to your \u003ccode\u003ecaches_page\u003c/code\u003e calls.\n* Set up a cronjob to periodically run the \u003ccode\u003epage_cache_sweeper\u003c/code\u003e script using something like this in your \u003ccode\u003ecrontab\u003c/code\u003e:\n\n    * * * * * www-data /usr/bin/ruby /path/to/my/rails_app/script/page_cache_sweeper\n\n* Tell your web server to use the new cache location using something like this in your config:\n\nApache\n\n    RewriteMap uri_escape int:escape\n    \u003cDirectory /path/to/my/rails_app/public/\u003e\n      RewriteEngine On\n      RewriteCond %{REQUEST_METHOD} GET [NC]\n      RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}%{REQUEST_URI}%{QUERY_STRING}.html -f\n      RewriteRule ^([^.]+)$ cache/%{HTTP_HOST}/$1${uri_escape:%{QUERY_STRING}}.html [L]\t\t\n\n      RewriteCond %{REQUEST_METHOD} GET [NC]\n      RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}/index.html -f\n      RewriteRule ^$ cache/%{HTTP_HOST}/index.html\n    \u003c/Directory\u003e\n\nnginx (thanks to cokron)\n\n    if (-f $document_root/cache/$host/$uri/index.html) {\n      rewrite (.*) /cache/$host/$1/index.html break;\n    }\n\n    if (-f $document_root/cache/$host/$uri.html) {\n      rewrite (.*) /cache/$host/$1.html break;\n    }\n\n== Where's the metadata?\n\nPageCacheFu sets the file modification timestamp of cached pages to the point in time when the cached page is set to expire. The sweeper is periodically checking the filesystem for files which have a modification timestamp that is past the current date and deletes those files.\n\nIf you have issues with future dates as modification timestamps or can't use the modification timestamps like this, PageCacheFu's page cache expiration mechanism might not be the right thing for you.\n\n== Options for +caches_page+\n\nYou can use the following options with \u003ccode\u003ecaches_page\u003c/code\u003e in your controllers:\n\n=== \u003ccode\u003e:expires_in\u003c/code\u003e\n\nUse this to specify a time interval after which the cache should expire. Example:\n\n    caches_page :show, :expires_in =\u003e 30.minutes\n\n(cokron says that \u003ccode\u003e:expires_in\u003c/code\u003e has to be specified. I didn't have time to verify and fix this yet. See issue #1)\n\n=== \u003ccode\u003e:include_query_string\u003c/code\u003e\n\nBy default, page_cache_fu stores the query string as part of the cached filename to enable caching for stuff like pagination and search results. You can disable this by setting this to \u003ccode\u003efalse\u003c/code\u003e, like so:\n\n    caches_page :show, :include_query_string =\u003e false\n\n=== \u003ccode\u003e:page_cache_directory\u003c/code\u003e\n\nBy default, page_cache_fu stores cached files in \u003ccode\u003e#{RAILS_ROOT}/public/cache/#{hostname}\u003c/code\u003e. If you want to override this, you can use this option. Examples:\n\n    caches_page :show, :page_cache_directory =\u003e '/'                     # yields #{RAILS_ROOT}/public/cache (without hostname)\n    caches_page :show, :page_cache_directory =\u003e '/../'                  # yields #{RAILS_ROOT}/public\n    caches_page :show, :page_cache_directory =\u003e '/../my_other_folder'   # yields #{RAILS_ROOT}/public/my_other_folder\n\n== Sweeper options\n\nThe sweeper is usually called via the \u003ccode\u003epage_cache_sweeper\u003c/code\u003e script. However, you can call \u003ccode\u003ePageCacheFu::CacheSweeper#sweep_if_expired\u003c/code\u003e on your own, if you like. It takes the cache directory as a first parameter and a hash of options as the second. These options are:\n\n=== \u003ccode\u003e:recursive\u003c/code\u003e\n\nSet this to \u003ccode\u003etrue\u003c/code\u003e to descend into subdirectories. (Default in the sweeper script)\n\n=== \u003ccode\u003e:match_mode\u003c/code\u003e\n\nRequired Unix file permissions. Specify this to tell the sweeper to skip files and directories which don't satisfy your required permissions. For example, \u003ccode\u003e:match_mode =\u003e 220\u003c/code\u003e will skip files which aren't writable by both the file owner and group. \n\n== Version\n\n0.1\n\n== Credits\n\nThe initial code for hostname based caching has been taken from Nate Bibler (initial post) and Andy Triggs (in the comments), http://launchpad.rocketjumpindustries.com/posts/5-defining-a-dynamic-page-cache-loction-by-subdomain-in-rails\n\nCopyright (c) 2009 Jan Schulz-Hofen, ROCKET RENTALS GmbH, released under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeah%2Fpage_cache_fu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeah%2Fpage_cache_fu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeah%2Fpage_cache_fu/lists"}