Comments (3)
It is possible to enable this. Pull requests are welcome :)
from staytus.
Heh, sorry, but I'm not developer, and I don't know ruby :)
I just tried, and I got browser caching working by etag,
--- app/controllers/pages_controller.rb_orig 2015-12-11 13:55:11.546157045 +0000
+++ app/controllers/pages_controller.rb 2015-12-11 14:01:34.199442336 +0000
@@ -1,5 +1,6 @@
class PagesController < ApplicationController
+ before_filter :allow_page_caching
before_filter { prepend_view_path(File.join(Staytus::Config.theme_root, 'views')) }
layout Staytus::Config.theme_name
@@ -70,4 +71,10 @@
end
end
+ def allow_page_caching
+ @events = Issue.ongoing.ordered.to_a + Service.ordered.includes(:status, {:active_maintenances => :service_status}).to_a + Maintenance.open.ordered.to_a
+ fresh_when(@events, public: true) unless Rails.env.development?
+ expires_in 1.minutes, public: true unless Rails.env.development?
+ end
+
end
but nginx caching don't works because there is some Cookie headers not in admin area:
mbp:~ ps$ curl http://hostname/ -I
HTTP/1.1 200 OK
Server: nginx/1.8.0
Date: Fri, 11 Dec 2015 14:01:47 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
ETag: "2780bc282138363eeae65db8156c6507"
Cache-Control: max-age=60, public
Set-Cookie: browser_id=fd7ede0a-df07-4a5e-9a10-194a77f989ef; path=/; expires=Tue, 11 Dec 2035 14:01:47 -0000
Set-Cookie: _staytus_session=T1VMQXJtQm15ckhSNnZHQzkwcEFTUXEwRmFmeENrOEhWUEtzdjNTV2VWMDhKSGpWcjVrN1BoTXJhU0NzanBDNzUzM2xodGFjV3JJUDl6WmpVTEU3WnN3TytOcWhyTjNXNkJST1FjaitNU215TkdGU0U5T3d0YnBRUERSYlgrQXErTnhVVHA2eTFNY3dJVmN0RVdpM1JRPT0tLVZTVkQyY1NVUVUySW4zN0d5dEhtY2c9PQ%3D%3D--fda76cafb2eb864f51fb263f3a54612aff2b735e; path=/; HttpOnly
X-Request-Id: dd8a24c1-3851-41b9-884a-4b6a09028006
X-Runtime: 0.032546
X-Cache-Status: MISS
mbp:~ ps$
and I don't know how to disable it. If you know how to disable "Set-Cookie" headers not in admin area, thats will be great, and nginx will cache all with config like:
[root@test ~]# cat /etc/nginx/conf.d/default.conf
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=default:8m max_size=20m inactive=1d;
proxy_temp_path /var/cache/nginx/tmp;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_cache default;
# proxy_ignore_headers Set-Cookie; # if I enable this option caching works
add_header X-Cache-Status $upstream_cache_status;
}
location /assets {
alias /home/staytus/staytus/public/assets;
}
}
[root@test ~]#
Thanks!
from staytus.
Seems I solved it on nginx side without any modifications in code, with config like:
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=default:8m max_size=20m inactive=1d;
proxy_temp_path /var/cache/nginx/tmp;
server {
listen 80;
server_name localhost;
location = / {
proxy_pass http://127.0.0.1:8080;
proxy_cache default;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
add_header X-Cache-Status $upstream_cache_status;
proxy_cache_valid any 30s;
}
location /robots.txt { return 200 "User-agent: *\nDisallow: /\n"; }
location / { proxy_pass http://127.0.0.1:8080; }
location /assets {
alias /home/staytus/staytus/public/assets;
}
}
from staytus.
Related Issues (20)
- Gemfile.lock blocks all installations and upgrades HOT 2
- Does staytus supports SSO login using OKTA
- Manteinances API Get endpoint HOT 1
- Ability to select subscribers when posting issue/maintenance HOT 1
- Private status pages and incidents
- mysql2 & MariaDB 10.5 Compatibility HOT 1
- Health Check
- How to install Staytus with Dokku
- Feature Request - Web Hooks
- Replace Google Fonts with self-hosted versions HOT 1
- [Feature Request] Password Resets
- Undefined method `arity'
- demo.staytus.co - Let`s Encrypt certificate expired on Sun, 03 Jul 2022 HOT 2
- environment.yml produces 502 Bad Gateway HOT 2
- Website not redirecting to https
- https://demo.staytus.co/ has no valid SSL Cert
- Status won't update with issue
- NoMethodError: undefined method `arity' for {:polymorphic=>true, :optional=>true}:Hash
- BCrypt::Error::InvalidHash in Setup Progress Admin User Creation HOT 1
- Some question
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from staytus.