seo_cache 0.19.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/pull_request_template.md +14 -0
- data/.travis.yml +39 -5
- data/CHANGELOG.md +7 -0
- data/CODE_OF_CONDUCT.md +11 -9
- data/CONTRIBUTING.md +21 -24
- data/README.md +59 -22
- data/lib/seo_cache/page_render.rb +2 -0
- data/lib/seo_cache/populate_cache.rb +1 -1
- data/lib/seo_cache/version.rb +1 -1
- data/seo_cache.gemspec +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b82b45544128dd934db5108a1ac3ee005b469a4ff930a2f30ab0c1f07053dea0
|
4
|
+
data.tar.gz: 674c9bd71f0742be48cb92fe1b2d1fe8c78567137a0feb7ff591174f563fc904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33e0310c7630322bed31cd4de556669959d469f3a5e8c2c4726d88d7a3b88dc7adf92fad7c33487afebc19cf69584d5ff9f9ea4ce019a4641e29385c40a2133d
|
7
|
+
data.tar.gz: c9667584c03fbe472807d9fa9875e5cb956052729c50bfd5e7a69177c105ca0a5d92f021826bfbbc9cee7419b972328594d01b316a8a50889e12310d55eacd8d
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Describe the bug**
|
11
|
+
A clear and concise description of what the bug is.
|
12
|
+
|
13
|
+
**To Reproduce**
|
14
|
+
Steps to reproduce the behavior:
|
15
|
+
1. Go to '...'
|
16
|
+
2. Click on '....'
|
17
|
+
3. Scroll down to '....'
|
18
|
+
4. See error
|
19
|
+
|
20
|
+
**Expected behavior**
|
21
|
+
A clear and concise description of what you expected to happen.
|
22
|
+
|
23
|
+
**Screenshots**
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
25
|
+
|
26
|
+
**Desktop (please complete the following information):**
|
27
|
+
- OS: [e.g. iOS]
|
28
|
+
- Browser [e.g. chrome, safari]
|
29
|
+
- Version [e.g. 22]
|
30
|
+
|
31
|
+
**Smartphone (please complete the following information):**
|
32
|
+
- Device: [e.g. iPhone6]
|
33
|
+
- OS: [e.g. iOS8.1]
|
34
|
+
- Browser [e.g. stock browser, safari]
|
35
|
+
- Version [e.g. 22]
|
36
|
+
|
37
|
+
**Additional context**
|
38
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for this project
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
12
|
+
|
13
|
+
**Describe the solution you'd like**
|
14
|
+
A clear and concise description of what you want to happen.
|
15
|
+
|
16
|
+
**Describe alternatives you've considered**
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
18
|
+
|
19
|
+
**Additional context**
|
20
|
+
Add any other context or screenshots about the feature request here.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
### Summary
|
2
|
+
|
3
|
+
Provide a general description of the code changes in your pull
|
4
|
+
request... were there any bugs you had fixed? If so, mention them. If
|
5
|
+
these bugs have open GitHub issues, be sure to tag them here as well,
|
6
|
+
to keep the conversation linked together.
|
7
|
+
|
8
|
+
### Other Information
|
9
|
+
|
10
|
+
If there's anything else that's important and relevant to your pull
|
11
|
+
request, mention that information here. This could include
|
12
|
+
benchmarks, or other information.
|
13
|
+
|
14
|
+
Thanks for contributing to SeoCache!
|
data/.travis.yml
CHANGED
@@ -1,7 +1,41 @@
|
|
1
1
|
---
|
2
|
-
sudo: false
|
3
2
|
language: ruby
|
4
|
-
|
5
|
-
|
6
|
-
-
|
7
|
-
|
3
|
+
|
4
|
+
gemfile:
|
5
|
+
- Gemfile
|
6
|
+
|
7
|
+
before_install:
|
8
|
+
- gem update --system -N
|
9
|
+
- gem install bundler -N
|
10
|
+
|
11
|
+
services:
|
12
|
+
- redis
|
13
|
+
|
14
|
+
addons:
|
15
|
+
apt:
|
16
|
+
packages:
|
17
|
+
- chromium-browser
|
18
|
+
|
19
|
+
cache:
|
20
|
+
bundler: true
|
21
|
+
directories:
|
22
|
+
- ~/.webdrivers
|
23
|
+
|
24
|
+
notifications:
|
25
|
+
email:
|
26
|
+
on_success: never
|
27
|
+
on_failure: change
|
28
|
+
|
29
|
+
script: bundle exec rake $RAKE_TASK
|
30
|
+
|
31
|
+
matrix:
|
32
|
+
include:
|
33
|
+
- rvm: 2.7
|
34
|
+
gemfile: Gemfile
|
35
|
+
env: RAKE_TASK=spec
|
36
|
+
- rvm: 2.6
|
37
|
+
gemfile: Gemfile
|
38
|
+
env: RAKE_TASK=spec
|
39
|
+
- rvm: 2.5
|
40
|
+
gemfile: Gemfile
|
41
|
+
env: RAKE_TASK=spec
|
data/CHANGELOG.md
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
In the interest of fostering an open and welcoming environment, we as
|
6
6
|
contributors and maintainers pledge to making participation in our project and
|
7
7
|
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression,
|
9
|
-
|
10
|
-
orientation.
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
11
11
|
|
12
12
|
## Our Standards
|
13
13
|
|
@@ -23,13 +23,13 @@ include:
|
|
23
23
|
Examples of unacceptable behavior by participants include:
|
24
24
|
|
25
25
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
26
|
+
advances
|
27
27
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
28
|
* Public or private harassment
|
29
29
|
* Publishing others' private information, such as a physical or electronic
|
30
|
-
|
30
|
+
address, without explicit permission
|
31
31
|
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
|
32
|
+
professional setting
|
33
33
|
|
34
34
|
## Our Responsibilities
|
35
35
|
|
@@ -68,7 +68,9 @@ members of the project's leadership.
|
|
68
68
|
## Attribution
|
69
69
|
|
70
70
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
72
|
|
73
|
-
[homepage]:
|
74
|
-
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/CONTRIBUTING.md
CHANGED
@@ -1,41 +1,38 @@
|
|
1
|
-
|
1
|
+
## How to contribute to Ruby on Rails
|
2
2
|
|
3
|
-
|
3
|
+
#### **Did you find a bug?**
|
4
4
|
|
5
|
-
|
5
|
+
* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead to contact us by email contact@ginkonote.com.
|
6
6
|
|
7
|
-
|
7
|
+
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/floXcoder/seo_cache/issues).
|
8
8
|
|
9
|
-
|
9
|
+
* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/floXcoder/seo_cache/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **scenario** demonstrating the expected behavior that is not occurring.
|
10
10
|
|
11
|
-
|
11
|
+
* If possible, use the relevant bug report templates to create the issue:
|
12
|
+
* [**Bug** issues](https://github.com/floXcoder/seo_cache/blob/develop/.github/ISSUE_TEMPLATE/bug_report.md)*
|
13
|
+
|
14
|
+
#### **Did you have an idea to improve the project?**
|
12
15
|
|
13
|
-
|
16
|
+
* Open a new GitHub issue request with your idea.
|
14
17
|
|
15
|
-
|
16
|
-
|
18
|
+
* If possible, use the relevant feature report templates to create the issue:
|
19
|
+
* [**Feature** issues](https://github.com/floXcoder/seo_cache/blob/develop/.github/ISSUE_TEMPLATE/feature_request.md)
|
17
20
|
|
18
|
-
|
19
|
-
gem "seo_cache", github: "floXcode/seo_cache"
|
20
|
-
```
|
21
|
+
#### **Did you write a patch that fixes a bug or do you intend to add a new feature or change an existing one?**
|
21
22
|
|
22
|
-
|
23
|
+
* Fork the project, write your code and open a new GitHub pull request with the patch.
|
23
24
|
|
24
|
-
|
25
|
-
- Complete backtraces for exceptions
|
25
|
+
* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
|
26
26
|
|
27
|
-
|
27
|
+
* If possible, use the relevant pull request report templates to create the issue:
|
28
|
+
* [**Pull Request**](https://github.com/floXcoder/seo_cache/blob/develop/.github/pull_request_template.md)
|
29
|
+
|
30
|
+
#### **Do you have questions about the source code?**
|
28
31
|
|
29
|
-
|
32
|
+
* You can contact me by email: flo@l-x.fr. I will try to answer as much I can and if available.
|
30
33
|
|
31
|
-
## Pull Requests
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
- Keep changes to a minimum. If you have multiple features or fixes, submit multiple pull requests.
|
36
|
-
- Follow the existing style. The code should read like it’s written by a single person.
|
37
|
-
|
38
|
-
Feel free to open an issue to get feedback on your idea before spending too much time on it.
|
35
|
+
Thanks!
|
39
36
|
|
40
37
|
---
|
41
38
|
|
data/README.md
CHANGED
@@ -1,14 +1,34 @@
|
|
1
1
|
# SeoCache
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/seo_cache.svg)](https://badge.fury.io/rb/seo_cache)
|
4
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
|
5
|
+
[![Build Status](https://travis-ci.org/floXcoder/seo_cache.svg)](https://travis-ci.org/floXcoder/seo_cache)
|
6
|
+
|
7
|
+
**SeoCache is a dedicated cache for SEO with JavaScript rendering** :fire:
|
8
|
+
|
9
|
+
You can find in this article, a more detail explanation of the purpose and usage of this gem:
|
10
|
+
|
11
|
+
- In english: https://www.ginkonote.com/users/flo/articles/seo-generate-and-cache-your-pages@seo
|
12
|
+
- In french: https://www.ginkonote.com/fr/utilisateurs/flo/articles/seo-generation-et-mise-en-cache-des-pages@seo
|
13
|
+
|
14
|
+
## Table of contents
|
15
|
+
- [Purpose](#purpose)
|
16
|
+
- [Installation](#installation)
|
17
|
+
- [Configuration](#configuration)
|
18
|
+
- [Helpers for controllers](#helpers-for-controllers)
|
19
|
+
- [Check cached pages](#check-cached-pages)
|
20
|
+
- [Automatic caching](#automatic-caching)
|
21
|
+
- [Server configuration](#server-configuration)
|
22
|
+
- [Inspiration](#inspiration)
|
23
|
+
- [Contributing](#contributing)
|
4
24
|
|
5
25
|
## Purpose
|
6
26
|
|
7
27
|
Google credo is: Don't waste my bot time!
|
8
28
|
|
9
|
-
|
29
|
+
In order to reduce Googlebot crawling time, let's provide the complete HTML files in a specific cache.
|
10
30
|
|
11
|
-
This cache is suitable for static (generated or not) pages but not for
|
31
|
+
This cache is suitable for static (generated or not) pages but not for user private pages.
|
12
32
|
|
13
33
|
## Installation
|
14
34
|
|
@@ -38,7 +58,7 @@ require 'seo_cache'
|
|
38
58
|
Rails.application.config.middleware.use SeoCache::Middleware
|
39
59
|
```
|
40
60
|
|
41
|
-
##
|
61
|
+
## Configuration
|
42
62
|
|
43
63
|
Chrome path (**required**) (`disk` or `memory`):
|
44
64
|
|
@@ -97,13 +117,13 @@ SeoCache.whitelist_hosts = []
|
|
97
117
|
URLs to blacklist:
|
98
118
|
|
99
119
|
```ruby
|
100
|
-
SeoCache.
|
120
|
+
SeoCache.blacklist_urls = %w[^/assets/.* ^/admin.*]
|
101
121
|
```
|
102
122
|
|
103
123
|
Params to blacklist:
|
104
124
|
|
105
125
|
```ruby
|
106
|
-
SeoCache.
|
126
|
+
SeoCache.blacklist_params = %w[page]
|
107
127
|
```
|
108
128
|
|
109
129
|
URLs to whitelist:
|
@@ -154,28 +174,36 @@ If you encounter the following error `DevToolsActivePort file doesn't exist`, yo
|
|
154
174
|
SeoCache.chrome_debugging_port = '9222'
|
155
175
|
```
|
156
176
|
|
157
|
-
Be aware, JS will be rendered twice: once by
|
177
|
+
Be aware, JS will be rendered twice: once by this gem and once by client. For React, this not a problem but with jQuery plugins, it can duplicate elements in the page (you have to check the redundancy).
|
158
178
|
|
159
|
-
Disk cache is recommended by default. Nginx will directly fetch
|
179
|
+
Disk cache is recommended by default. Nginx will directly fetch HTML files on disk. The TTFB (time to first byte) will be under 200ms :). You can use memory cache if you have lot of RAM, but if you shut down your server, you will lost all the generated pages! So prefer cache disk storage.
|
160
180
|
|
161
|
-
##
|
181
|
+
## Helpers for controllers
|
162
182
|
|
163
183
|
You can check if seo mode is active in your controllers, with the following variable:
|
164
184
|
|
165
185
|
```ruby
|
166
|
-
|
186
|
+
def check_seo_mode
|
187
|
+
@seo_mode = (params.key?(SeoCache.prerender_url_param) || params.key?(SeoCache.force_cache_url_param))
|
188
|
+
end
|
189
|
+
```
|
190
|
+
|
191
|
+
And if you want to access to this variable in JS files:
|
192
|
+
|
193
|
+
```javascript
|
194
|
+
window.seoMode = "{@seo_mode}"
|
167
195
|
```
|
168
196
|
|
169
197
|
|
170
|
-
##
|
198
|
+
## Check cached pages
|
171
199
|
|
172
|
-
Too see in browser the
|
200
|
+
Too see in browser the cached page, open a browser and set the user agent to:
|
173
201
|
|
174
202
|
`Googlebot (Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html))`
|
175
203
|
|
176
|
-
For instance, with Chrome or Chromium, you can change the user agent in "Network conditions" panel.
|
204
|
+
For instance, with Chrome or Chromium, you can change the user agent in "Network" / "Network conditions" panel.
|
177
205
|
|
178
|
-
To (re)cache a page, add this parameter to the url (the browser must use the Googlebot user agent):
|
206
|
+
To (re)cache a page, add this parameter to the url (and the browser must use the Googlebot user agent):
|
179
207
|
|
180
208
|
`/?_seo_cache_=true`
|
181
209
|
|
@@ -184,7 +212,7 @@ To (re)cache a page, add this parameter to the url (the browser must use the Goo
|
|
184
212
|
To automate caching, create a cron rake task (e.g. in `lib/tasks/populate_seo_cache.rake`):
|
185
213
|
|
186
214
|
```ruby
|
187
|
-
namespace :
|
215
|
+
namespace :my_project do
|
188
216
|
|
189
217
|
desc 'Populate cache for SEO'
|
190
218
|
task populate_seo_cache: :environment do |_task, _args|
|
@@ -197,14 +225,14 @@ namespace :MyProject do
|
|
197
225
|
end
|
198
226
|
```
|
199
227
|
|
200
|
-
You can add the `force_cache: true` option to `SeoCache::PopulateCache` for overwrite
|
228
|
+
You can add the `force_cache: true` option to `SeoCache::PopulateCache` for overwrite cached data.
|
201
229
|
|
202
|
-
If you want to
|
230
|
+
If you want to execute only through a rake task, you can comment the line which include the middleware. keep all options configured and remove only the middleware. Thus all pages will be cached and SeoCache isn't called for pages not in cache.
|
203
231
|
It's useful if you have a script which generates all website pages (based on sitemap for instance) and you run script every day.
|
204
232
|
|
205
|
-
## Server
|
233
|
+
## Server configuration
|
206
234
|
|
207
|
-
If you use disk caching, add to your Nginx configuration:
|
235
|
+
If you use disk caching, add this to your Nginx configuration:
|
208
236
|
|
209
237
|
```nginx
|
210
238
|
# Before any block:
|
@@ -250,15 +278,24 @@ location / {
|
|
250
278
|
}
|
251
279
|
|
252
280
|
location @rubyproxy {
|
253
|
-
|
281
|
+
proxy_connect_timeout 600;
|
282
|
+
proxy_send_timeout 600;
|
283
|
+
proxy_read_timeout 600;
|
284
|
+
send_timeout 600;
|
285
|
+
proxy_set_header Host $host;
|
286
|
+
proxy_set_header X-Real-IP $remote_addr;
|
287
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
288
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
289
|
+
proxy_pass_header Server;
|
290
|
+
proxy_pass http://0.0.0.0:3020;
|
254
291
|
}
|
255
292
|
```
|
256
293
|
|
257
|
-
This configuration allow you to use SEO cache only for bots (you can add other bots) and GET requests. For users, you don't want to use the cached page (user connection, basket, ...). The performance are less important for users
|
294
|
+
This configuration allow you to use SEO cache only for bots (you can add other bots at the beginning of the file) and HTML GET requests. For connected users, you don't want to use the cached page (user connection, basket, ...). The performance are less important for users than bots.
|
258
295
|
|
259
296
|
## Heroku case
|
260
297
|
|
261
|
-
If you use Heroku server, you can't store
|
298
|
+
If you use Heroku server, you can't store files on dynos. But you have two alternatives:
|
262
299
|
|
263
300
|
- Use the memory mode
|
264
301
|
|
data/lib/seo_cache/version.rb
CHANGED
data/seo_cache.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency 'selenium-webdriver', '~> 3'
|
29
29
|
spec.add_dependency 'webdrivers', '~> 4'
|
30
30
|
|
31
|
-
spec.add_development_dependency 'bundler', '~>
|
31
|
+
spec.add_development_dependency 'bundler', '~> 2'
|
32
32
|
spec.add_development_dependency 'rake', '~> 13'
|
33
33
|
spec.add_development_dependency 'rspec', '~> 3'
|
34
34
|
spec.add_development_dependency 'simplecov', '~> 0.17'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seo_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FloXcoder
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '2'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '2'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,6 +186,9 @@ executables: []
|
|
186
186
|
extensions: []
|
187
187
|
extra_rdoc_files: []
|
188
188
|
files:
|
189
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
190
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
191
|
+
- ".github/pull_request_template.md"
|
189
192
|
- ".gitignore"
|
190
193
|
- ".rspec"
|
191
194
|
- ".rubocop.yml"
|