A powerful and lightweight caching plugin for WordPress that dramatically improves website performance through intelligent page caching and code minification.
- Stores rendered pages as static HTML files
- Serves cached content before WordPress loads for maximum speed
- Configurable cache expiry from 1 hour to 1 week
- Automatic cache invalidation on content updates
- HTML Minification - Removes unnecessary whitespace and comments
- CSS Minification - Minifies inline
<style>blocks - JavaScript Minification - Minifies inline
<script>blocks - Safe minification that preserves
<pre>,<code>, and<textarea>content
- Exclude specific URLs with wildcard support
- Cookie-based exclusions (great for WooCommerce)
- Automatic exclusions for:
- Admin pages
- AJAX requests
- REST API requests
- Search results
- 404 pages
- Preview pages
- Password-protected posts
Pre-configured exclusions for:
/cart//checkout//my-account/- Cart cookies (prevents caching when items in cart)
- Beautiful, responsive settings page
- Real-time cache statistics
- One-click cache clearing
- Admin bar integration for quick access
- WordPress 5.0 or higher
- PHP 7.4 or higher
- Go to Plugins β Add New
- Search for "Samrat Website Cache"
- Click Install Now then Activate
- Navigate to Website Cache β Settings to configure
- Download the latest release
- Upload the
samrat-website-cachefolder to/wp-content/plugins/ - Activate through the Plugins menu
- Configure at Website Cache β Settings
The plugin works out of the box with sensible defaults:
| Setting | Default |
|---|---|
| Page Cache | β Enabled |
| Cache for Logged-in Users | β Disabled |
| Cache Expiry | 24 hours |
| HTML Minification | β Disabled |
| CSS Minification | β Disabled |
| JS Minification | β Disabled |
For most websites, simply activate and you're done!
| Option | Description |
|---|---|
| Enable Page Cache | Toggle page caching on/off |
| Cache for Logged-in Users | Enable caching for authenticated users (not recommended for dynamic content) |
| Cache Expiry Time | How long to keep cached pages (1 hour - 1 week) |
| Option | Description |
|---|---|
| Minify HTML | Remove whitespace and comments from HTML |
| Minify CSS | Minify inline CSS styles |
| Minify JavaScript | Minify inline JavaScript code |
Exclude Pages - Enter URL paths to exclude (one per line):
/cart/
/checkout/
/my-account/
/api/*
/contact/
Exclude Cookies - Skip caching when these cookies exist:
woocommerce_cart_hash
woocommerce_items_in_cart
custom_session_cookie
Look for this comment at the bottom of your HTML:
<!-- Cached by Samrat Website Cache on 2024-01-15 10:30:00 -->X-Samrat-Cache: HIT
X-Samrat-Cache-Time: 2024-01-15 10:30:00
Visit Website Cache β Settings to see:
- Number of cached pages
- Total cache size
- Cache status (Active/Inactive)
- Settings Page - Click "Clear All Cache" button
- Admin Bar - Click "Cache β Clear Cache"
- Clear Cache Page - Visit Website Cache β Clear Cache
Cache automatically clears when:
- Posts/pages are updated or deleted
- Theme is changed
- Plugins are activated/deactivated
- WordPress core is updated
- WooCommerce stock changes
samrat-website-cache/
βββ assets/
β βββ css/
β β βββ admin.css # Admin styles
β βββ js/
β βββ admin.js # Admin JavaScript
βββ cache/ # Cached HTML files
βββ includes/
β βββ AdminMenu.php # Admin menu & settings
β βββ CacheHandler.php # Core caching logic
βββ README.md # This file
βββ readme.txt # WordPress.org readme
βββ samrat-website-cache.php # Main plugin file
// Fires after cache is cleared
do_action('samrat_cache_cleared');
// Fires after a single page cache is cleared
do_action('samrat_cache_page_cleared', $post_id);// Modify cache settings
$settings = apply_filters('samrat_cache_settings', $settings);
// Modify excluded pages
$excluded = apply_filters('samrat_cache_excluded_pages', $excluded_pages);
// Modify cache key
$cache_key = apply_filters('samrat_cache_key', $cache_key, $url);- Check if page caching is enabled in settings
- Ensure you're not logged in (unless "Cache for Logged-in Users" is enabled)
- Check if the page URL is in exclusion list
- Verify no excluded cookies are present
- Clear cache and try again
- Disable HTML minification
- Disable CSS minification
- Clear cache after changes
- Check for JavaScript errors in console
- Check file permissions on
/cache/directory - Ensure WordPress has write access
- Try clearing manually via FTP/file manager
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the GPLv2 or later - see the LICENSE file for details.
Samrat Hossen
- Website: samrat-personal-portfolio.netlify.app
- GitHub: @samrathossen
- WordPress Plugin Development Team
- The WordPress community for continuous support and feedback
β If you find this plugin helpful, please consider giving it a star on GitHub!
