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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93939e53687c186d003b4b09abed06bcf1b6ac0a63b808c3a7abfadd7e6531cb
4
- data.tar.gz: 4d362ee26521e0ebb55b61c15e6b9d5e6c9e19877e57ead9cfab9765c4310142
3
+ metadata.gz: b82b45544128dd934db5108a1ac3ee005b469a4ff930a2f30ab0c1f07053dea0
4
+ data.tar.gz: 674c9bd71f0742be48cb92fe1b2d1fe8c78567137a0feb7ff591174f563fc904
5
5
  SHA512:
6
- metadata.gz: fc485c1ea013d77fcf9337c3423bacec563701b319d79b4949304f6bf51fe78c54a3553cdf875b8067e60c1c9c8ae3667dfeec0ee8f29f3991079d5662c3ffa7
7
- data.tar.gz: 1d634743d69e52965d9c450b046dc19edabd88b92783c567c460a11b7407473d395600775cd5aaff31f96db5b68fa5143954f90fa7b154fbccf76f3f9284e00b
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!
@@ -1,7 +1,41 @@
1
1
  ---
2
- sudo: false
3
2
  language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.1
7
- before_install: gem install bundler -v 1.16.1
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
@@ -1,3 +1,10 @@
1
+ ## 1.0.0
2
+
3
+ - Update Readme (badges, syntax, links, ...)
4
+ - Add Travis CI
5
+ - Update dependencies
6
+ - Do not cache pages in error
7
+
1
8
  ## 0.19.0
2
9
 
3
10
  - Add option to cache page if user connected
@@ -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, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
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
- address, without explicit permission
30
+ address, without explicit permission
31
31
  * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
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 [http://contributor-covenant.org/version/1/4][version]
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
72
 
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
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
@@ -1,41 +1,38 @@
1
- # Contributing
1
+ ## How to contribute to Ruby on Rails
2
2
 
3
- First, thanks for wanting to contribute. You’re awesome! :heart:
3
+ #### **Did you find a bug?**
4
4
 
5
- ## Help
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
- We’re not able to provide support through GitHub Issues. If you’re looking for help with your code, try posting on [Stack Overflow](https://stackoverflow.com/).
7
+ * **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/floXcoder/seo_cache/issues).
8
8
 
9
- All features should be documented. If you don’t see a feature in the docs, assume it doesn’t exist.
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
- ## Bugs
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
- Think you’ve discovered a bug?
16
+ * Open a new GitHub issue request with your idea.
14
17
 
15
- 1. Search existing issues to see if it’s been reported.
16
- 2. Try the `master` branch to make sure it hasn’t been fixed.
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
- ```rb
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
- If the above steps don’t help, create an issue. Include:
23
+ * Fork the project, write your code and open a new GitHub pull request with the patch.
23
24
 
24
- - Detailed steps to reproduce
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
- ## New Features
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
- If you’d like to discuss a new feature, create an issue and start the title with `[Idea]`.
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
- Fork the project and create a pull request. A few tips:
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
- Cache dedicated for SEO with Javascript rendering :fire:
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
- So to reduce Googlebot crawling time, let's provide HTML files in a specific cache.
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 connected pages.
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
- ## Options
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.blacklist_params = %w[^/assets/.* ^/admin.*]
120
+ SeoCache.blacklist_urls = %w[^/assets/.* ^/admin.*]
101
121
  ```
102
122
 
103
123
  Params to blacklist:
104
124
 
105
125
  ```ruby
106
- SeoCache.blacklist_urls = %w[page]
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 server rendering 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).
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 file on disk. The TTFB (time to first byte) will be under 200ms :). You can use memory cache if you have lot of RAM.
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
- ## Controllers
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
- request.env['seo_mode']
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
- ## Consult cache pages
198
+ ## Check cached pages
171
199
 
172
- Too see in browser the cache page, open a browser and set the user agent to:
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 :MyProject do
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 cache data.
228
+ You can add the `force_cache: true` option to `SeoCache::PopulateCache` for overwrite cached data.
201
229
 
202
- If you want to only 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 not called for pages not in cache.
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 then bots.
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 file on dynos. But you have two alternatives :
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
 
@@ -14,6 +14,8 @@ module SeoCache
14
14
  return @driver.page_source
15
15
  rescue StandardError => error
16
16
  SeoCache.log_error(error.message)
17
+
18
+ return false
17
19
  ensure
18
20
  @driver&.quit if quit_after_render
19
21
  end
@@ -27,7 +27,7 @@ module SeoCache
27
27
  url += "#{SeoCache.prerender_url_param}=true"
28
28
 
29
29
  page_source = @page_render.get(url, false)
30
- @page_caching.cache(page_source, path)
30
+ @page_caching.cache(page_source, path) if page_source
31
31
  end
32
32
 
33
33
  ensure
@@ -1,3 +1,3 @@
1
1
  module SeoCache
2
- VERSION = '0.19.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -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', '~> 1'
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.19.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-05-11 00:00:00.000000000 Z
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: '1'
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: '1'
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"