Content Versioning System: Autosave, Rollback, and Diff for CMS

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1All 2062 services
Content Versioning System: Autosave, Rollback, and Diff for CMS
Complex
~3-5 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1358
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1251
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    956
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1188
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    929
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    947

Editors accidentally overwriting content? Recovering lost edits is a common headache in CMS work. Without versioning, every edit can be irreversible, and auditing changes becomes impossible. We develop content versioning systems that preserve every version of your content, allow comparison, and enable instant rollback to any point.

The stakes without versioning are high: restoring accidentally deleted content can cost $500–$2,000 per incident depending on volume and uniqueness. For editorial teams with 10+ authors, incidents happen every few months. A content versioning system pays for itself after the first 1–2 incidents, typically saving $5,000–$10,000 annually, and completely eliminates irretrievable losses.

In one project with 50 editors, the system saved up to 200 versions per day. After a year, zero data loss. This reliability comes from a sound architecture: full snapshots instead of diff chains, well-considered storage limits, and automatic autosave every 30 seconds. Versioning also provides an audit trail, compliance support, and the ability to A/B test content.

What problem does versioning solve?

In commercial projects, content is modified by dozens of editors. Simultaneous edits, accidental deletions, failed experiments — without a change history, you risk losing hours of work. The content versioning system addresses three key issues:

  • Rollback to a previous version — if a new edit doesn't work, restore the old one in one click.
  • Version comparison — see which fields changed and who made the edit.
  • Audit trail — a log of editor actions for compliance.

Why full snapshots are faster than Event Sourcing

Approach Storage Recovery Complexity
Event Sourcing Diffs chain Slow (replay O(n)) High
Full snapshots Full copies Instant (O(1)) Low
Hybrid Snapshots + diffs Medium Medium

Full snapshots are 10x faster than Event Sourcing for recovery: no need to replay an event chain. For typical content (articles, pages), snapshot size is small (2–10 KB), and simplicity and reliability outweigh space savings. Hybrid approaches are only warranted for extremely large data volumes (>100 MB per entity).

Comparison: storage and performance

Parameter Event Sourcing Full snapshots Hybrid
Storage volume Low (10 MB over 1000 versions) High (100 MB over 1000 versions) Medium
Recovery speed Low (O(n)) High (O(1)) Medium
Implementation complexity High Low Medium
Audit Full Partial Full

How we implement the content versioning system

Data model

content_versions (
  id, content_type, content_id,
  version_number,
  content (jsonb),     -- full snapshot of data
  title, excerpt,      -- for quick display in version list
  changed_fields (jsonb), -- ['title', 'body'] — what exactly changed
  change_summary,      -- 'Fixed typo in title'
  is_autosave,         -- autosave vs manual save
  created_by, created_at
);

Autosave

// Autosave every 30 seconds on changes
const { isDirty, formData } = useFormState();

useEffect(() => {
    if (!isDirty) return;

    const timer = setTimeout(async () => {
        await saveDraft(formData);
        setLastSaved(new Date());
    }, 30000);

    return () => clearTimeout(timer);
}, [formData, isDirty]);

Creating a version on save

class ContentObserver
{
    public function updating(Content $content): void
    {
        $dirty = $content->getDirty();
        $versionableFields = ['title', 'body', 'excerpt', 'meta_title', 'meta_description'];
        $changedVersionable = array_intersect(array_keys($dirty), $versionableFields);

        if (empty($changedVersionable)) return;

        // Version limit: keep at most 50, delete old autosaves
        ContentVersion::where('content_type', get_class($content))
            ->where('content_id', $content->id)
            ->where('is_autosave', true)
            ->orderBy('created_at', 'desc')
            ->skip(10)  // keep last 10 autosaves
            ->get()
            ->each->delete();

        ContentVersion::create([
            'content_type'    => get_class($content),
            'content_id'      => $content->id,
            'version_number'  => $this->getNextVersionNumber($content),
            'content'         => $content->only($versionableFields),
            'title'           => $content->title,
            'changed_fields'  => $changedVersionable,
            'is_autosave'     => request()->header('X-Autosave') === 'true',
            'created_by'      => auth()->id()
        ]);
    }
}

Diff between versions

use cogpowered\FineDiff\Diff;
use cogpowered\FineDiff\Granularity\Word;

class ContentVersionDiff
{
    public function diff(ContentVersion $v1, ContentVersion $v2): array
    {
        $result = [];
        $fields = array_unique(array_merge(
            array_keys($v1->content),
            array_keys($v2->content)
        ));

        foreach ($fields as $field) {
            $old = $v1->content[$field] ?? '';
            $new = $v2->content[$field] ?? '';

            if ($old !== $new) {
                $diff = new Diff(new Word());
                $result[$field] = [
                    'old'  => $old,
                    'new'  => $new,
                    'diff' => $diff->render($old, $new)
                ];
            }
        }

        return $result;
    }
}

Restoring a version

public function restore(Content $content, ContentVersion $version): void
{
    DB::transaction(function () use ($content, $version) {
        // Save current state as a version before restoring
        event(new ContentBeforeRestore($content));

        $content->update($version->content);
        $content->recordActivity('version_restored', [
            'restored_version' => $version->version_number
        ]);
    });
}

Which fields should be versioned?

Typically text and HTML fields: title, body (including markup), excerpt, meta_title, meta_description. Media files (images, videos) don't need versioning — just store links. If content includes nested blocks (e.g., a page builder), additional normalization is required — we add a content_version_components table with versions of each component, allowing rollback of individual blocks without affecting the rest.

Process of work

  1. Analysis — identify fields to version, storage limits, autosave settings.
  2. Design — data model, API, history interface.
  3. Implementation — write code in PHP + JavaScript, integrate the FineDiff library.
  4. Testing — verify version creation, rollback, comparison.
  5. Deployment — deploy to staging, then to production.

What's included

  • API and data model documentation
  • Source code of the versioning module
  • Repository access
  • Autosave configuration (every 30 seconds)
  • Version comparison interface with color highlighting
  • Notifications to editor on rollback to previous version
  • Editor training (2 hours)
  • One month of technical support after launch
  • Estimated cost: $5,000–$15,000 depending on scope

Estimated timeline

Basic system (autosave + rollback) — 1 to 2 weeks ($5K–$10K). Full system with diff and comparison interface — 2 to 4 weeks ($10K–$15K). Cost is calculated individually — contact us for an estimate.

Our team has over 5 years of experience in CMS development. We guarantee support and refinements after implementation. A ready-to-use module easily integrates into existing Laravel projects without changing core business logic — just attach the Observer and run the database migration. Reach out for a consultation — we'll discuss your project, assess data volume, and propose the optimal solution within a day.

CMS development: solving real editorial bottlenecks, not installing plugins

A news publisher had a WordPress site with 5 editors. Every article required 15 minutes of manual formatting because the WYSIWYG mangled pasted text. After 6 months, the database had 12 different font sizes and 7 custom colors. The redesign would cost $30k just to clean up the mess — and no one would admit it.

We develop content management systems (CMS) that prevent this from day one. Instead of free-form <textarea> hell, we design structured content models, custom WYSIWYG editors using ProseMirror, and media libraries that offload to S3+CDN within two sprints. This is CMS development without shortcuts.

When is headless CMS justified and when not?

Headless CMS (Strapi, Contentful, Sanity) decouples content management from frontend rendering — the API serves content to any client: website, mobile app, smart display. You get omnichannel delivery and a React/Vue frontend that never touches the admin panel. But if your editors need “save and see” preview and you have no separate frontend team, headless costs extra: you must build a preview layer or use a service like Vercel’s preview deployments.

Sanity customises Studio down to the field level — each field is a React component you can replace. Portable Text (its rich content format) ports to any renderer via custom serializers. For complex editorial workflows with multiple authors, Sanity is the best choice. Contentful offers stable cloud infrastructure with a marketplace of extensions, but monthly bills scale with content volume — typical enterprise plans are $500–$2,000/month. Strapi is self-hosted, open source, with a TypeScript API and custom fields via plugins, but you manage the hosting and backups.

Traditional CMS (WordPress, Craft CMS) works when editors need a familiar admin UI and the frontend is rendered server-side. Craft CMS provides Matrix fields, flexible entry structures, and built-in localization — it’s a professional tool for content teams that need granular permissions and versioning.

How do we build a WYSIWYG editor that doesn’t break layout?

The editor is the most complex component — not a <textarea>. The sweet spot is Tiptap, built on ProseMirror. Every element (headings, lists, tables, code blocks, images) is an extension. Collaborative editing via Yjs works out of the box. Lexical (Meta) is more performant (>60fps typing on mobile) but harder to extend. TinyMCE is a corporate standard at 300KB bundle, but it generates dirty HTML on paste — inline styles, nested <span>, &nbsp; everywhere.

The root cause: pasting from Word. font-family, mso-* properties, empty <span> tags — all leak into the page unless you sanitize. We configure ProseMirror’s pasteRule with DOMPurify to strip everything except allowed tags. Result: clean, semantic HTML that survives a redesign without manual cleanup. Editors save 2–4 hours per week per person.

Media library: from upload to CDN with transformation

Saving files to the server disk is the classic mistake. The disk fills, scaling fails, and CDN becomes impossible. The correct pipeline: upload to S3-compatible storage (AWS S3, Cloudflare R2, MinIO) → CDN (CloudFront, Cloudflare) → on‑the‑fly transformations.

Imgproxy or Thumbor generate any size and format dynamically: https://img.example.com/resize:800:600/format:webp/plain/s3://bucket/photo.jpg. The original lives once, derivatives never occupy disk. Cloudflare Images costs $5 per 100k images, including transformations. Video uploads use Cloudflare Stream or Mux — encode to HLS, adaptive streaming for any bandwidth. Without this, a 1080p video (500MB) loads entirely before play, causing a 5–8 second delay on 3G.

What’s included in media library development

Component Technology Timeline (weeks)
Upload and storage in S3 AWS SDK / MinIO 1–2
Image transformations Imgproxy / Thumbor 1–2
Video streaming Cloudflare Stream / Mux 1–2
Upload and sorting UI React + @dnd-kit/sortable 1–3
Migration of existing files Custom script 0.5–1

Why structured content outperforms free-form HTML

Free-form WYSIWYG leads to chaos in a year: 7 font sizes, 12 colors, random margins. Redesign requires manual cleanup of thousands of posts. Structured content stores “what” instead of “how”: not <p style="font-size:24px; color:red">Important!</p>, but a callout block with variant: warning. The CMS stores the structure; the frontend decides rendering. Sanity Portable Text, Contentful Rich Text, and Strapi Dynamic Zones all follow this pattern — and it reduces rework by 70% during redesigns.

Typical editorial time savings with structured content
  • A news site with 50 articles per week: editors save 10 hours/week on formatting.
  • A corporate portal with 1000 existing pages: migration from free-form to structured content takes 3–5 days, cutting page load by 40% (cleaner HTML).

Work process

  1. Analysis of editorial workflows — who edits, how often, what content (articles, landing pages, product data), whether localization is needed.
  2. CMS selection — based on scenarios, not trends. We compare headless vs traditional with a weighted matrix.
  3. Content model design — record types, fields, relationships, validation rules.
  4. Implementation — frontend integration, editor customization, media library, previews.
  5. Testing — real‑world scenarios: paste from Word, upload 100+ files simultaneously, load test the API (200 req/s target).
  6. Deployment and documentation — editor guide (text + video), API description, access credentials, 1 month support.

Timelines and budget

Type of work Timeline Budget
Integration of headless CMS (Strapi/Sanity) into existing Next.js project 2–5 weeks Discussed individually
Custom WYSIWYG editor with Tiptap and specific blocks 2–4 weeks Discussed individually
Media library with S3 + transformations 1–3 weeks Discussed individually
Full CMS system from scratch 4–10 weeks Discussed individually

Budget is calculated individually after an audit. Client examples: a mid‑sized media site saved $40k/year by eliminating manual formatting; an e‑commerce platform reduced time‑to‑publish by 60% with a headless Sanity setup. Contact us for a free project estimate.

What you get after delivery

  • Working CMS with configured access rights (admin, editor, reviewer)
  • Full content model documentation and API reference
  • Editor training documentation (text + video)
  • Code covered by tests (PHPUnit for Laravel, Jest for JS)
  • 1 month post‑launch support with SLA

Our experience and guarantees

Over 40 completed CMS projects — from small editorial sites to enterprise media portals with 200k daily unique visitors. We use licensed tools (Sentry for error monitoring, SonarCloud for code quality) and guarantee zero critical bugs at launch. All code is version‑controlled and deployable via CI/CD.

For your specific needs, contact us to discuss requirements. We’ll provide a technical proposal within 2 business days.