-
-
Save libkazz/3798193 to your computer and use it in GitHub Desktop.
switch rails page cache by user agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http { | |
| ... | |
| server { | |
| listen 8080; | |
| server_name localhost; | |
| # | |
| # Set User Agent type | |
| # | |
| set $ua_type "pc"; | |
| if ($http_user_agent ~* '(iPhone|iPod|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)') { | |
| set $ua_type "mobile"; | |
| } | |
| location / { | |
| root /var/www/app/public; | |
| # Rewrite for page cache | |
| # | |
| # e.g.) | |
| # pc: public/pc/xxx.html | |
| # mobile: public/mobile/xxx.html | |
| # | |
| try_files $ua_type$uri $ua_type$uri.html $ua_type$uri/index.html @localhost; | |
| } | |
| location @localhost { | |
| proxy_pass http://127.0.0.1; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment