Commit Graph

70 Commits

Author SHA1 Message Date
Mike Jolley b5219aac31 Add extra cache headers 2019-02-19 16:35:26 +00:00
Mike Jolley 7f0ac47291 Fix callback args 2019-02-06 12:15:29 +00:00
Mike Jolley dc01d1de76 Deprecate delete_version_transients 2019-01-21 13:08:01 +00:00
Mike Jolley 8ede6bcb74 Added helpers to clean transients during shutdown and clean layered nav counts 2019-01-21 13:00:21 +00:00
Rodrigo Primo eea4810c49 Revert change to defer transient cleanup
This commit reverts commits 2f8a3eae49 and 17e97c2580 that were created to defer transient cleanup (see #20537) and avoid deadlocks on the wp_options table (see #20528 and #17632). The problem is that deferring transient cleanup to a cron job created an issue when creating or importing multiple products at once (see #21100 and https://github.com/woocommerce/wc-smooth-generator/issues/14#issuecomment-413342136) and has the potential to impact the checkout as well if we start using more versioned transients for orders.

This problem is happening because when importing or creating multiple products at once, for each product that is created or imported, WooCommerce core enqueues a few 'delete_version_transients' cron events. Events are enqueued faster than they are executed and after a few hundred products are generated, the size of the cron queue, which is stored in a single wp_options entry, starts to impact WordPress performance in general.

To reduce the chance of deadlocks happening again after this change, I already created another PR to optimize the query used to delete transients (#21274) by avoiding an unnecessary filesort, and I'm planning, on a subsequent commit, to improve it further by prefixing the transient name with its version instead of suffixing it as it is currently done. But the ultimate solution for high traffic stores is to use a persistent cache plugin.
2019-01-21 12:58:19 +00:00
Mike Jolley 2d44e90542 CS 2019-01-16 14:47:59 +00:00
Miguel Pinto 0537145113
Add filter to hash location to change hash format
Ability to define a cache version only based on country, and not a region, city, etc.
Improve website performance by decreasing the number of different versions.
In my case, i was able to define v=[country_code] which is more URL friendly.
2019-01-06 13:58:12 +13:00
Rodrigo Primo b4b7062d7b Improve performance of the query to delete version transients
This commit removes the `ORDER BY option_id` part of the query to remove the version transients from the `wp_options` table. This change should help users having performance issues with this query (see for example #21215) and, as far as I can see, ordering is not necessary in this context.

Removing the `ORDER BY` from the query means that MySQL won't have to use filesort:

```
MySQL [wccore]> explain DELETE FROM wp_options WHERE option_name LIKE '\\_transient\\_%1510258328' ORDER BY option_id LIMIT 1000;
+----+-------------+------------+------------+-------+---------------+-------------+---------+-------+------+----------+-----------------------------+
| id | select_type | table      | partitions | type  | possible_keys | key         | key_len | ref   | rows | filtered | Extra                       |
+----+-------------+------------+------------+-------+---------------+-------------+---------+-------+------+----------+-----------------------------+
|  1 | DELETE      | wp_options | NULL       | range | option_name   | option_name | 766     | const |   67 |   100.00 | Using where; Using filesort |
+----+-------------+------------+------------+-------+---------------+-------------+---------+-------+------+----------+-----------------------------+
1 row in set (0.02 sec)

MySQL [wccore]> explain DELETE FROM wp_options WHERE option_name LIKE '\\_transient\\_%1510258328' LIMIT 1000;
+----+-------------+------------+------------+-------+---------------+-------------+---------+-------+------+----------+-------------+
| id | select_type | table      | partitions | type  | possible_keys | key         | key_len | ref   | rows | filtered | Extra       |
+----+-------------+------------+------------+-------+---------------+-------------+---------+-------+------+----------+-------------+
|  1 | DELETE      | wp_options | NULL       | range | option_name   | option_name | 766     | const |   67 |   100.00 | Using where |
+----+-------------+------------+------------+-------+---------------+-------------+---------+-------+------+----------+-------------+
1 row in set (0.00 sec)
```
2018-09-04 17:20:35 -03:00
Mike Jolley 17e97c2580 Clear version cache if time is unchanged 2018-06-15 13:56:23 +01:00
Mike Jolley 9b0de1a221 Missing static keyword 2018-06-14 16:35:34 +01:00
Mike Jolley 2f8a3eae49 Defer all transient cleanup 2018-06-14 14:40:08 +01:00
Mike Jolley c326115db2 Clear category 0 when deleting caches 2018-05-30 13:29:44 +01:00
Mike Jolley 461dfd6489 Avoid query if no limit is set. 2018-05-01 13:26:57 +01:00
Rodrigo Primo 18a8a6b752 Don't schedule event to delete transients if limit set to 0
Third-party code can set the limit of transients to be deleted to 0 using the filter `woocommerce_delete_version_transients_limit`. If this happens, the code shouldn't schedule a cron event to delete more transients to avoid flooding the list of cron jobs.

Fixes #19890
2018-04-27 10:31:45 -03:00
ahmedofali d06854a0b4 Defining array before attempting to append to it 2018-03-25 18:28:14 +00:00
Mike Jolley d052b2ee46 cache per parent to avoid large caches 2018-03-13 19:00:08 +00:00
Mike Jolley 49c2f2b28e Also during clean_term_cache 2018-02-28 18:35:58 +00:00
Mike Jolley 4bce7b0223 Use single cache for hierarchy 2018-02-28 18:24:03 +00:00
Mike Jolley 4b2642c757 phpcs 2018-02-26 19:18:38 +00:00
Mike Jolley 997b852a43 clean_term_cache callback to flush subcategory cache 2018-02-26 19:15:42 +00:00
Rodrigo Primo 257feb63bd Fix doc typo 2018-01-18 16:50:27 -02:00
Mike Jolley 9f059e17a9 Add helper function instead of calling method, and restore old method for bw compat 2017-11-08 15:07:00 +00:00
Mike Jolley 45c6f0e00d Restore old function name and phpcs 2017-11-08 14:54:13 +00:00
Gerhard Potgieter 7b9fb6c0cb Change nocache_headers hook firing (#17540)
* wp hook is too late to fire the nocache_headers filter, some caching plugins read it before that it seems.

* Create do_not_cache_page helper function and call that instead of nocache_headers

* Must add checks to prevent caching on certain pages as well

* Nothing to return
2017-11-08 14:27:30 +00:00
Mike Jolley 3d55a45bfa Only change nocacheheaders when on a cart/checkout page 2017-10-16 21:29:23 -07:00
Claudio Sanches a13158a75a Apply wc_maybe_define_constant() in all places 2017-09-05 16:52:39 -03:00
Mike Jolley 299fcc327c Merge remote-tracking branch 'origin/master'
# Conflicts:
#	includes/class-wc-cache-helper.php
2017-08-07 17:11:26 +01:00
Mike Jolley 622b4b35d6 Remove white space 2017-08-07 17:10:36 +01:00
Mike Jolley af1dce3544 Set nocache constants on all nocache_headers 2017-08-07 11:01:38 +01:00
Marian Kadanka 6183a840db Fix product category archives not being cached due to inconsistency
Wordpress function get_queried_object_id() returns conflicting IDs
for pages and product category archives which in current
implementation results in product category archives possibly not
being cached if their tag ID conflicts with Woocommerce's special
page IDs - cart, checkout, etc.

Let's switch to implementation using is_page() to address this.
2017-07-31 20:47:19 +02:00
Mike Jolley 6cea4e87cc Compare page IDs rather than URIs in the cache helper 2017-06-20 12:09:46 +01:00
Rasmus Bengtsson 185934fad9 Fix phpdoc to include params and correct types 2017-05-15 13:50:52 +02:00
Mike Jolley 00ed627b29 Data stores 2016-11-14 18:18:08 +00:00
Justin Stern a3e371e0d7 Make WooCommerce core play nice with Codeception (#11845)
If is_blog_installed() is false then skip some installation steps that
are performed on the 'init' action and which require the database to be
available
2016-11-09 11:53:39 +00:00
Claudio Sanches 1481f1f7b4 Include trailing slash in REQUEST_URI before compare for prevent caching 2016-11-08 17:14:31 -02:00
Rami Yushuvaev 140d0efb99 i18n: Avoid using HTML tags in translation strings (#12166)
* i18n: Remove some HTML tags from translation strings

* i18n: simpler translation string

* i18n: translations strings with surrounding `<strong>` HTML tags should be moved outside the translation string

* i18n: Avoide using `<code>' HTML tags in translation strings

* i18n: Split the notice to avoide using HTML tags in translation strings
2016-10-24 21:56:37 -02:00
Matty ae75f8b8cd Adjusts all references of 'woothemes' to 'woocommerce' in relevant URLs, excluding the Travis CI integration which correctly uses 'woocommerce/woocommerce'. 2016-09-28 12:17:40 +02:00
Aristeides Stathopoulos d4e3faf014 PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket 2016-09-02 04:51:31 +03:00
Aristeides Stathopoulos 0516e96843 PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket 2016-09-02 04:33:57 +03:00
Aristeides Stathopoulos 82f3cc221e WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeOpenParenthesis 2016-08-27 07:23:02 +03:00
Justin Shreve e65ab6adec start transfering things to billing_ prefix 2016-03-17 12:39:29 -07:00
Justin Shreve 25430afd33 Make session loading work correctly, add an alias for address_1 and shipping_address_1, fix total spent and order count 2016-03-17 09:41:12 -07:00
Claudio Sanches 3e955f6086 [2.5] Create new function to prevent endpoint indexing 2016-03-01 13:45:25 -03:00
Mike Jolley 8edf6d9286 Noindex endpoints
Closes #10433
2016-02-29 12:52:45 +00:00
Mike Jolley 9ba5b7ee26 Add helpers to get and increment cache prefixes
Allows wp_cache to be invalidated with 1 call
2015-11-13 23:06:38 +00:00
Claudio Sanches ee30b5b308 Fixed php docs standards 2015-11-03 11:31:20 -02:00
Mike Jolley b3a3a998bb Add trailing slash in get_page_uris to reduce likelihood of conflicts
Fixes #9386
2015-10-22 16:33:05 +01:00
Mike Jolley 821434cbb7 Fix geolocation redirect with querystring 2015-09-07 16:58:05 +01:00
Mike Jolley cf7a9c3913 Case insentiive matching in cache helper
@georgestephanis
2015-09-01 16:40:17 +01:00
Mike Jolley f7e4bf224d Exclude cart and account pages from geolocation
Closes #8967
2015-09-01 15:41:05 +01:00