Thực hiện Targeted Drupal Cache Clears bằng Drush

Thực hiện Targeted Drupal Cache Clears bằng Drush

he standard Drush command for clearing Drupal's cache looks like this:

drush cache-clear all

(You can also use the shortened alias cclike this: drush cc all)

These commands give you the same result as when you click that cache clear button in the UI  it clears all of Drupal's internal caches.

But clearing all of Drupal's caches at once can be overkill. You usually don't need to clear everything, and doing so can put heavy load on your servers (especially if your site is large or gets a lot of traffic). Beneath the surface, Drupal's caching is actually pretty granular, and tools like Drush give us the ability to target and clear caches on the subsystem level.

Using Drush, you can see your caching options with:

	# Using the shortened alias from this point on.
	drush cc

Which returns something like this:

[0] : cancel
[1] : all
[2] : drush
[3] : theme registry
[4] : menu
[5] : css+js
[6] : block
[7] : module list
[8] : theme list
[9] : registry
...

Let's look at what each of these does (as a quick note, I'm specifically looking at Drush 6, which is the major version at this time):

drush cc all

Remember how I said that this does the same thing as the cache clear button in the UI? Well, that's technically false. Yes, drush cc allwill clear all your Drupal caches (as long as it can bootstrap Drupal), but it will also clear its own internal Drush cache. That's why when Drush cannot bootstrap Drupal, you will still see a success command saying 'drush' cache was cleared.

drush cc drush

This only clears Drush's internal cache (the same one I just mentioned). You don't need a Drupal site available to clear this cache.

drush cc theme registry

This command simply calls drupal_theme_rebuild()to rebuild the theming system. This is needed whenever new ".tpl.php" files or theme hooks are added to the system. This specific cache clear only applies for Drupal 7 and up.

drush cc menu

This runs a menu rebuild, which refreshes the database tables used by various menu functions. For example, any new router items (like those defined in hook_menu) are added to the menu_linkstable, and stale ones are removed. This also clears the page and block caches, to prevent the display of stale menu links.

drush cc css+js

If you have CSS or JS aggregation enabled, this will rebuild the aggregated files. It also increments the query string on CSS & JS links, forcing clients that have cached an old copy to download a fresh one.

drush cc block

Block caching exists so Drupal doesn't have to look up the locations and visibility of blocks with each page load. This command refreshes that cache.

drush cc module list

This re-scans the module directories in your codebase and refreshes Drupal's internal list of which modules are available.

drush cc theme list

This re-scans the theme directories in your codebase and refreshes Drupal's internal list of which themes are available.

drush cc registry

Drupal maintains an internal registry of all functions or classes in the system, allowing it to lazy-load code files as needed (reducing the amount of code that must be parsed on each request). The list of these files is known as the "code registry" and it is stored in the systemtable in your Drupal database. This cache clear will look at this list of files and update the contents of any files that have been changed. Note: it will not rebuild the registry from scratch. For more information, see registry_update.

drush cc ?????

You may see other options in this list, because contributed modules (like views and advanced aggregation) can add their own kinds of cache clears. In each case, you'll see a file in the contrib module named something like mymodule.drush.incthat contains the code which defines what the cache clear does.

If you want to see what each of these options does on a code level, you can download Drush and inspect the file found at Drush/commands/core/cache.drush.inc.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Quảng cáo việc làm

 

Thích hợp các bạn nữ mảng thợ may làm việc tại nước NGA

Đơn hàng Tuyển dụng 100 Thợ may đi Nga(đợt 1 tháng 3.2021, đợt 2 tháng 5.2021). Lương thực lãnh 800 USD, bao ăn ở, vé máy bay và visa, phí xuất cảnh(1800 USD)trả khi đi làm có lương. Bạn có thể liên hệ CÔNG TY qua Phone/Zalo: (+84) 944 225 212. Công ty sẽ tư vấn cho bạn.

Xem chi tiết: >>> https://bit.ly/3o9NOfR

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Chiến lược Backlink “trâu bò” có hiệu quả?

Chiến lược Backlink “trâu bò” có hiệu quả?

Chiến lược Link Building nào giúp website có 54 backlink hạ bệ website có 958 backlinks?

Thống kê các bức ảnh được nhiều “like” nhất trên Facebook

Với bố cục đơn giản vã thông điệp rõ ràng, những bức ảnh khu nghỉ mát, váy cưới hay giỏ hoa quả của nhiều công ty đã được hàng triệu lượt người dùng “thích” trên Facebook.

3 Modules giúp Debug Emails trong Drupal 7

3 Modules giúp Debug Emails trong Drupal 7

Debugging email issues in Drupal can be really painful. Problems can exist in multiple areas; like Drupal itself or your mail server.