Skip to content

Commit 204d98d

Browse files
authored
Merge branch 'master' into master
2 parents 3b8c802 + 4c1918f commit 204d98d

17 files changed

+885
-303
lines changed

.github/workflows/create.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ jobs:
1515
EXCLUDE_LIST: .gitattributes .gitignore .travis.yml README.md deploy.sh readme.sh
1616
tests map.conf nginx.log wercker.yml vendor
1717
SLUG: nginx-helper
18-
WORDPRESS_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }}
19-
WORDPRESS_USERNAME: ${{ secrets.WORDPRESS_USERNAME }}
18+
WORDPRESS_PASSWORD: ${{ secrets.SVN_PASSWORD }}
19+
WORDPRESS_USERNAME: ${{ secrets.SVN_USERNAME }}

.github/workflows/e2e-test.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ name: End-to-End Tests
55
# Controls when the workflow will run
66
on:
77
# Triggers the workflow on push or pull request events but only for the main branch
8-
push:
9-
branches:
10-
- develop
11-
- master
8+
# push:
9+
# branches:
10+
# - develop
11+
# - master
1212

13-
pull_request:
14-
branches:
15-
- develop
16-
- master
13+
# pull_request:
14+
# branches:
15+
# - develop
16+
# - master
1717

1818
# Allows you to run this workflow manually from the Actions tab
1919
workflow_dispatch:
@@ -52,7 +52,7 @@ jobs:
5252

5353
- name: Archive HTML Report on failure
5454
if: failure()
55-
uses: actions/upload-artifact@v1
55+
uses: actions/upload-artifact@v4
5656
with:
5757
name: report
5858
path: ./tests/e2e-playwright/config

Development.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Development
2+
[ For internal contributors only ]
3+
4+
## Getting Started
5+
6+
To set up the repo locally, choose one of the following methods:
7+
8+
### Method 1 (For FastCGI or Srcache)
9+
10+
1. Create a WordPress website.
11+
2. Clone the [nginx](https://github.com/nginx/nginx) source code in a separate directory.
12+
3. Set up nginx using either FastCGI cache or Srcache module.
13+
4. Manually compile the binary for Nginx.
14+
5. Add a configuration block to redirect incoming requests to the WordPress website.
15+
6. Clone this repository inside the `wp-content/plugins` directory.
16+
17+
### Method 2 (For Redis Cache)
18+
19+
1. Install EasyEngine by following the [instructions](https://easyengine.io/docs/install/).
20+
2. Create a site with caching enabled using the command: `ee site create <site_name> --cache`
21+
22+
3. Clone this repository inside the `wp-content/plugins` directory of the newly created site.
23+
24+
## Testing
25+
26+
To verify if a page is cached:
27+
28+
1. Enable the timestamp option in Nginx Helper from the WordPress Admin Page:
29+
- This adds a comment with cache time and query count.
30+
- Cached pages should show only 1 query.
31+
32+
2. Manually check the Redis database:
33+
- Search for keys beginning with the prefix specified in your Redis config, followed by a URL.
34+
35+
## Contributing
36+
37+
### Raising a Pull Request (PR)
38+
39+
1. Create a new branch from `master` for your changes.
40+
2. Make your changes and commit them to your branch.
41+
3. Raise a PR targeting the `develop` branch.
42+
4. Assign the PR to a reviewer.
43+
5. Address any feedback and make necessary changes.
44+
6. Once approved, merge the PR into the `develop` branch.
45+
46+
### Merging to Master
47+
48+
1. After thorough testing on the `develop` branch, create a new PR.
49+
2. Set the source branch as the original feature branch that was merged into `develop`.
50+
3. Set the target branch as `master`.
51+
4. Assign reviewers and await final approval.
52+
5. Once approved, merge the PR into the `master` branch.

README.md

+51-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Nginx Helper #
22
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
33

4-
**Contributors:** rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, darren-slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel, gagan0123, ravanh, michaelbeil, samedwards, niwreg, entr, nuvoPoint, iam404, rittesh.patel, vishalkakadiya, BhargavBhandari90, vincent-lu, murrayjbrown, bryant1410, 1gor, matt-h, pySilver, johan-chassaing, dotsam, sanketio, petenelson, nathanielks, rigagoogoo, dslatten, jinschoi, kelin1003, vaishuagola27, rahulsprajapati, Joel-James, utkarshpatel, gsayed786, shashwatmittal, sudhiryadav, thrijith, stayallive, jaredwsmith, abhijitrakas, umeshnevase, sid177, souptik, arafatkn, subscriptiongroup, akrocks
4+
**Contributors:** rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, darren-slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel, gagan0123, ravanh, michaelbeil, samedwards, niwreg, entr, nuvoPoint, iam404, rittesh.patel, vishalkakadiya, BhargavBhandari90, bryant1410, 1gor, matt-h, dotsam, nathanielks, rigagoogoo, dslatten, jinschoi, kelin1003, vaishuagola27, rahulsprajapati, utkarshpatel, gsayed786, shashwatmittal, sudhiryadav, thrijith, stayallive, jaredwsmith, abhijitrakas, umeshnevase, sid177, souptik, arafatkn, subscriptiongroup, akrocks, vedantgandhi28, GridPane, stefanfisk, SGr33n, agvs
55

6-
**Tags:** nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
6+
**Tags:** nginx, cache-purge, fastcgi, permalinks, redis-cache
77

88
**Requires at least:** 3.0
99

10-
**Tested up to:** 6.1
10+
**Tested up to:** 6.7
1111

12-
**Stable tag:** 2.2.5
12+
**Stable tag:** 2.3.3
1313

1414
**License:** GPLv2 or later (of-course)
1515

@@ -99,6 +99,10 @@ To purge a page immediately, follow these instructions:
9999
* Just open this in a browser and the page will be purged instantly.
100100
* Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
101101

102+
**Q. Does it need any kind of URL structure?**
103+
104+
Yes. When setting the URL structure in Nginx configuration file a trailing slash should always be added.
105+
102106
### FAQ - Nginx Redis Cache ###
103107

104108
**Q. Can I override the redis hostname, port and prefix?**
@@ -113,6 +117,18 @@ define( 'RT_WP_NGINX_HELPER_REDIS_PORT', '6000' );
113117
define( 'RT_WP_NGINX_HELPER_REDIS_PREFIX', 'page-cache:' );
114118
```
115119

120+
**Q. Can I override the redis socket path, username, password?**
121+
122+
Yes, you can force override the redis socket path, username, password by defining constant in wp-config.php. For example:
123+
124+
```php
125+
define( 'RT_WP_NGINX_HELPER_REDIS_UNIX_SOCKET', '/var/run/redis/redis.sock' );
126+
127+
define( 'RT_WP_NGINX_HELPER_REDIS_USERNAME', 'admin' );
128+
129+
define( 'RT_WP_NGINX_HELPER_REDIS_PASSWORD', 'admin' );
130+
```
131+
116132
### FAQ - Nginx Map ###
117133

118134
**Q. My multisite already uses `WPMU_ACCEL_REDIRECT`. Do I still need Nginx Map?**
@@ -123,6 +139,16 @@ Definitely. `WPMU_ACCEL_REDIRECT` reduces the load on PHP, but it still ask Word
123139

124140
Most likely yes. A wordpress plugin, if not using explicitly any Apache-only mod, should work on Nginx. Some plugin may need some extra work.
125141

142+
143+
### FAQ - WP-CLI ###
144+
145+
**Q. How can I update the options using WP-CLI?**
146+
147+
```shell
148+
wp option patch update rt_wp_nginx_helper_options <option_name> <option_value>
149+
```
150+
151+
126152
### Still need help! ###
127153

128154
Please post your problem in [our free support forum](https://github.com/rtCamp/nginx-helper/issues).
@@ -139,6 +165,27 @@ Please post your problem in [our free support forum](https://github.com/rtCamp/n
139165

140166
## Changelog ##
141167

168+
### 2.3.3 ###
169+
170+
* Fix AMP Purge for method unlink. [#396](https://github.com/rtCamp/nginx-helper/issues/343) - by [Stefan Fisk](https://github.com/stefanfisk)
171+
172+
### 2.3.2 ###
173+
174+
* Update the contributors list for the plugin. [#343](https://github.com/rtCamp/nginx-helper/issues/343) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
175+
176+
### 2.3.1 ###
177+
178+
* Update the contributors list and tags for the plugin. [#378](https://github.com/rtCamp/nginx-helper/issues/378) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
179+
180+
### 2.3.0 ###
181+
182+
* Disable the purge functionality when importing data. [#52](https://github.com/rtCamp/nginx-helper/pull/52) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
183+
* Added option to preload cache for all Post and Pages. [#47](https://github.com/rtCamp/nginx-helper/pull/47) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
184+
* Added the capability to purge Amp URL's. [#135](https://github.com/rtCamp/nginx-helper/pull/135) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
185+
* Add support for adding Username, Password support for Redis. It also includes the support for Unix Socket Path for Redis along with Database selection. [#343](https://github.com/rtCamp/nginx-helper/pull/343),[#350](https://github.com/rtCamp/nginx-helper/pull/350) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
186+
* Add capability to allow modifying options using WP-CLI. [#307](https://github.com/rtCamp/nginx-helper/pull/307) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
187+
* Fix the plugin crash issue due to internationalization after upgrading to WordPress Version 6.7. [#364](https://github.com/rtCamp/nginx-helper/pull/364) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
188+
142189
### 2.2.5 ###
143190

144191
* Add the capability to enable/disable purging of feeds. [#281](https://github.com/rtCamp/nginx-helper/issues/281) - by [Amaan Khan](https://github.com/pathan-amaankhan)

admin/class-fastcgi-purger.php

+23
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,30 @@ public function purge_url( $url, $feed = true ) {
9090
break;
9191

9292
}
93+
94+
if( ( is_page() || is_single() ) && $nginx_helper_admin->options['purge_amp_urls'] ) {
95+
$this->purge_amp_version( $url );
96+
}
97+
98+
}
99+
100+
/**
101+
* Purge AMP version of a URL.
102+
*
103+
* @param string $url_base The base URL to purge.
104+
*/
105+
private function purge_amp_version( $url_base ) {
106+
global $nginx_helper_admin;
93107

108+
$amp_url = sprintf( '%s/amp/', rtrim( $url_base, '/' ) );
109+
110+
$this->log( '- Purging AMP URL | ' . $amp_url );
111+
112+
if ( 'unlink_files' === $nginx_helper_admin->options['purge_method'] ) {
113+
$this->delete_cache_file_for( $amp_url );
114+
} else {
115+
$this->do_remote_get( $amp_url );
116+
}
94117
}
95118

96119
/**

0 commit comments

Comments
 (0)