ShahiTranslate

Translation Cache System

Overview

The translation cache system stores translated content for rapid retrieval, dramatically improving site performance and reducing API costs.

How Translation Caching Works

Basic Flow

  1. Request: Visitor selects a language
  2. Cache Check: System looks for cached translation
  3. Cache Hit: If found, serve instantly (milliseconds)
  4. Cache Miss: If not found, generate translation
  5. Store: Save new translation to cache
  6. Serve: Display to visitor
  7. Cache Storage

    Translations are stored in:

    • Database: WordPress database tables (wpstptranslations)
    • Object Cache: Redis/Memcached if available
    • File Cache: Optional file-based caching
    • CDN Cache: Compatible with CDN caching layers
    • Cache Configuration

      Location: ShahiTranslate Pro → Settings → General → Cache Settings

      Enable/Disable Caching

    • Enable Translation Cache: ✅ On (recommended)
    • – Improves performance by 10-50x
      – Reduces API costs by 90%+
      – Essential for production sites

    • Disable for Development: ⬜ Off
    • – Useful during testing
      – See changes immediately
      – Not recommended for live sites

      Cache Duration

      Default: 30 days

      Settings:

    • Short (7 days): For frequently updated content
    • Medium (30 days): Standard, balanced approach
    • Long (90 days): For static content, saves API costs
    • Permanent: Never expire (manual clear only)
    • Custom: Set specific duration in hours/days
    • Considerations:

    • Longer = Better performance, lower costs
    • Shorter = More up-to-date automatic translations
    • Balance based on content update frequency
    • Cache Invalidation

      Automatic Invalidation:

    • When post/page is updated
    • When manual translation is added/edited
    • When source content changes
    • When plugin settings change
    • Manual Invalidation:

    • Clear all cache
    • Clear specific language
    • Clear specific post/page
    • Clear by date range
    • Cache Types

      Page Cache

      What It Caches: Complete page translations

      Benefits:

    • Fastest possible loading
    • Entire page served from cache
    • No database queries needed
    • Limitations:

    • More storage required
    • May cache dynamic elements
    • Best For: Static pages, blog posts, product pages

      Fragment Cache

      What It Caches: Individual content pieces

      Benefits:

    • More flexible than page cache
    • Allows dynamic elements
    • Smaller storage footprint
    • Limitations:

    • Slightly slower than page cache
    • More complex to manage
    • Best For: Sites with dynamic content, personalization

      Translation Memory Cache

      What It Caches: Common phrases and segments

      Benefits:

    • Consistency across site
    • Reduces redundant translations
    • Speeds up new content translation
    • How It Works:

    • Recognizes repeated phrases
    • Reuses existing translations
    • Builds over time
    • Example:

    • “Add to Cart” appears on 100 product pages
    • Translated once, reused 100 times
    • Consistent translation everywhere
    • Cache Performance

      Storage Optimization

      Database Optimization:

    • Indexed tables for fast lookups
    • Automatic cleanup of old entries
    • Compressed storage (reduces size by 40-60%)
    • Object Cache Integration:

    • Redis support
    • Memcached support
    • APCu support
    • Automatic detection and use
    • File Cache (Optional):

    • Store translations as static files
    • Served directly by web server
    • Fastest possible delivery
    • Cache Statistics

      Location: ShahiTranslate Pro → Dashboard → Cache Statistics

      Metrics Displayed:

    • Total Cached Items: Number of translations stored
    • Cache Size: Storage space used
    • Hit Rate: Percentage served from cache
    • Miss Rate: Percentage requiring new translation
    • API Calls Saved: Estimated cost savings
    • Average Load Time: Performance improvement
    • Using Statistics:

    • Monitor cache effectiveness
    • Identify underperforming content
    • Optimize cache settings
    • Track cost savings
    • Cache Management

      Clearing Cache

      Location: ShahiTranslate Pro → Settings → General → Cache Settings → Clear Cache

      Options:

    • Clear All Cache
    • – Removes all cached translations
      – Use when: Plugin updated, major changes made
      – Impact: Temporary performance decrease

    • Clear Specific Language
    • – Remove cache for one language only
      – Use when: Language-specific issues
      – Impact: Minimal, affects only that language

    • Clear by Post Type
    • – Clear posts, pages, or custom post types
      – Use when: Content structure changed
      – Impact: Moderate, specific content type affected

    • Clear by Date
    • – Remove cache older than X days
      – Use when: Want to refresh old translations
      – Impact: Varies based on date range

    • Clear Single Item
    • – Remove cache for specific post/page
      – Use when: Individual page updated
      – Impact: Minimal, one item only

      When to Clear Cache:

    • After plugin updates
    • When translations look wrong
    • After theme changes
    • When testing new configurations
    • Periodically (e.g., monthly) for freshness
    • Automatic Cleanup

      Auto-Cleanup Settings:

    • Enable Auto-Cleanup: ✅ On
    • Cleanup Interval: Daily, weekly, or custom
    • Keep Last: Keep translations from last X days
    • Max Size: Limit cache size (GB)
    • What Gets Cleaned:

    • Translations older than retention period
    • Orphaned translations (content deleted)
    • Duplicate entries
    • Corrupted cache entries
    • Cache Warming

      What It Is: Pre-populate cache before visitors arrive

      Benefits:

    • No “first visitor” slowdown
    • Consistent fast performance
    • Better user experience
    • How to Use:

    • Manual Warming:
    • – Go to ShahiTranslate Pro → Tools → Warm Cache
      – Select language(s) to warm
      – Choose content to translate
      – Click “Start Cache Warming”

    • Automatic Warming:
    • – Enable in settings
      – Runs after content published
      – Background processing (doesn’t slow site)

    • Scheduled Warming:
    • – Set up cron job
      – Warm cache at low-traffic times
      – Ensure cache always full

      Configuration:

    • Pages to Warm: All, published, recent, or custom list
    • Languages: Which languages to warm
    • Schedule: Immediate, hourly, daily
    • Batch Size: How many items per batch (prevents timeouts)
    • Cache and Performance

      Page Load Times

      Without Cache:

    • Translation API call: 200-500ms
    • Database queries: 50-100ms
    • Total delay: 250-600ms per page
    • With Cache:

    • Cache retrieval: 5-20ms
    • No API calls needed
    • Total delay: 5-20ms per page
    • Improvement: 10-100x faster

      API Cost Savings

      Example Scenario:

    • 10,000 page views/month
    • 3 languages
    • Without cache: 30,000 API calls
    • With cache (95% hit rate): 1,500 API calls
    • Savings: 95% reduction in API costs
    • Monthly Cost Comparison:

    • Without cache: ~$60/month (at $20/1M characters)
    • With cache: ~$3/month
    • Savings: $57/month
    • Hosting Resource Usage

      Memory:

    • Cache stored in database or object cache
    • Minimal RAM usage
    • Object cache (Redis) more efficient than database
    • CPU:

    • Cache hits require minimal processing
    • Reduces server load significantly
    • Allows handling more concurrent visitors
    • Database:

    • Indexed tables for fast queries
    • Minimal database load
    • Regular cleanup prevents bloat
    • Advanced Caching

      Object Cache Integration

      Supported Systems:

    • Redis (recommended for high-traffic sites)
    • Memcached
    • APCu
    • WinCache
    • Setup:

    • Install object cache on server (ask hosting provider)
    • Install WordPress object cache plugin (e.g., Redis Object Cache)
    • ShahiTranslate Pro auto-detects and uses it
    • No additional configuration needed
    • Benefits:

    • 5-10x faster than database cache
    • Reduces database load
    • Scales better for high traffic
    • CDN Caching

      Compatible CDNs:

    • Cloudflare
    • KeyCDN
    • StackPath
    • Amazon CloudFront
    • All major CDN providers
    • How It Works:

    • Translated pages cached at CDN edge servers
    • Served from location nearest to visitor
    • Bypasses your server entirely
    • Setup:

    • Enable language-specific caching on CDN
    • Configure cache keys to include language parameter
    • Set appropriate cache durations
    • Test with multiple languages
    • Configuration Example (Cloudflare):
      `
      Cache Key:

    • URL with language parameter (/es/, /fr/, etc.)
    • Cookie: stp_language
    • Cache TTL: 1 day
      `

      Multi-Level Caching Strategy

      Level 1 – Browser Cache:

    • Visitor’s browser caches pages
    • Fastest possible (0ms load time)
    • Duration: 1 hour – 1 day
    • Level 2 – CDN Cache:

    • CDN edge servers cache pages
    • Very fast (10-50ms)
    • Duration: 1 day – 1 week
    • Level 3 – Server Object Cache:

    • Redis/Memcached on your server
    • Fast (5-20ms)
    • Duration: 1 week – 1 month
    • Level 4 – Database Cache:

    • Stored in WordPress database
    • Fast (20-100ms)
    • Duration: 1 month – permanent
    • Result: Maximum performance at every level

      Troubleshooting Cache Issues

      Cache Not Working

      Check:

    • Cache is enabled in settings
    • Disk space available
    • Database tables created properly
    • No caching plugin conflicts
    • Solution:

    • Enable cache in settings
    • Verify database tables exist
    • Check error logs
    • Temporarily disable other caching plugins
    • Stale Content

      Issue: Old translations showing after content update

      Causes:

    • Cache not invalidated on update
    • Very long cache duration
    • External caching layer not cleared
    • Solutions:

    • Manually clear cache for affected content
    • Reduce cache duration
    • Configure CDN to purge on update
    • Enable automatic cache invalidation
    • High Storage Usage

      Issue: Cache consuming too much disk space

      Solutions:

    • Reduce cache duration
    • Enable auto-cleanup
    • Set maximum cache size
    • Use compression (enabled by default)
    • Limit cached languages
    • Performance Not Improving

      Check:

    • Cache hit rate (should be >90%)
    • Object cache properly configured
    • No database bottlenecks
    • CDN working correctly
    • Solutions:

    • Warm cache for popular content
    • Optimize database (repair/optimize tables)
    • Verify object cache plugin active
    • Check CDN configuration
    • Best Practices

      Recommended Settings

      For Most Sites:

    • Cache Enabled: ✅ Yes
    • Duration: 30 days
    • Auto-Cleanup: Enabled, weekly
    • Object Cache: Use if available
    • Cache Warming: Enable for top pages
    • For High-Traffic Sites:

    • Cache Enabled: ✅ Yes
    • Duration: 90 days
    • Object Cache: Redis (required)
    • CDN: Enabled
    • Cache Warming: Scheduled, all content
    • For Frequently Updated Sites:

    • Cache Enabled: ✅ Yes
    • Duration: 7 days
    • Auto-Cleanup: Enabled, daily
    • Invalidate on Update: ✅ Yes
    • Selective warming: Recent content only
    • Monitoring

      What to Monitor:

    • Cache hit rate (aim for 95%+)
    • Average page load time
    • API usage and costs
    • Storage usage
    • Error rates
    • Tools:

    • Plugin dashboard
    • Google Analytics (page speed)
    • Server monitoring (APM tools)
    • API provider dashboard (Google Cloud)
    • Actions Based on Monitoring:

    • Low hit rate → Warm cache, increase duration
    • High API costs → Check cache working
    • Slow pages → Enable object cache, CDN
    • High storage → Enable cleanup, reduce duration
    • Next Steps

    • Performance Optimization
    • SEO Settings
    • Troubleshooting Cache Issues

Share this article

Was this article helpful?

Help us improve our documentation

Still need help?

Our support team is ready to assist you with personalized guidance for your workspace.

Submit a support ticket