Opened 7 years ago

Closed 7 years ago

#2799 closed defect (bug) (fixed)

Cache 'dynamic' Javascript

Reported by: mdawaffe Owned by: mdawaffe
Priority: normal Milestone: 2.1
Component: Administration Version: 2.1
Severity: normal Keywords: has-patch 2nd-opinion
Cc:

Description

The PHP generated Javascript files are not being cached properly.

Attached:

  1. Call wp-config.php instead of admin.php to avoid cache blocking and unnecessary overhead.
  2. Send Cache-control: max-age=2600000, must-revalidate

These scripts only need the PHP for i18n (if that), so the ~1 month long freshness period shouldn't hurt.

Attachments (2)

2799.diff (1.8 KB) - added by mdawaffe 7 years ago.
2799b.diff (2.2 KB) - added by mdawaffe 7 years ago.

Download all attachments as: .zip

Change History (5)

require_once('../wp-config.php');
header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
header('Cache-control: max-age=2600000, must-revalidate', true);  // ~1 month

I see those three lines listed three times, and there will probably be other times as we add more JS functionality in the future. Wanna move that to an include so that there's one place to go to edit it all?

Well if you'd like to be clever about it, sure :)

2799b.diff

  1. wp-includes/js/js-headers.php gets the include right and sends the headers.

comment:3   ryan7 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [4109]) cache_javascript_headers() from masquerade. fixes #3059 #2799

Note: See TracTickets for help on using tickets.